1
0
Fork 0

Improved http error handling

This commit is contained in:
Michael 2021-10-29 23:21:07 +00:00
commit 4236a9a105
55 changed files with 282 additions and 135 deletions

View file

@ -23,7 +23,7 @@ namespace Friendica\Factory\Api\Mastodon;
use Friendica\BaseFactory;
use Friendica\Database\Database;
use Friendica\Network\HTTPException\InternalServerErrorException;
use Friendica\Network\HTTPException\UnprocessableEntityException;
use Psr\Log\LoggerInterface;
class Application extends BaseFactory
@ -42,13 +42,13 @@ class Application extends BaseFactory
*
* @return \Friendica\Object\Api\Mastodon\Application
*
* @throws InternalServerErrorException
* @throws UnprocessableEntityException
*/
public function createFromApplicationId(int $id): \Friendica\Object\Api\Mastodon\Application
{
$application = $this->dba->selectFirst('application', ['client_id', 'client_secret', 'id', 'name', 'redirect_uri', 'website'], ['id' => $id]);
if (!$this->dba->isResult($application)) {
throw new InternalServerErrorException(sprintf("ID '%s' not found", $id));
throw new UnprocessableEntityException(sprintf("ID '%s' not found", $id));
}
return new \Friendica\Object\Api\Mastodon\Application(