From: Michael Date: Wed, 12 May 2021 03:05:22 +0000 (+0000) Subject: Improved error handling X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=d1e109d9beda95fa0e043f3e4e9f19cfaa4ad42f;p=friendica.git Improved error handling --- diff --git a/src/Factory/Api/Mastodon/Error.php b/src/Factory/Api/Mastodon/Error.php index 2c3662288e..086cceef98 100644 --- a/src/Factory/Api/Mastodon/Error.php +++ b/src/Factory/Api/Mastodon/Error.php @@ -35,4 +35,31 @@ class Error extends BaseFactory System::jsonError(404, $errorobj->toArray()); } + + public function UnprocessableEntity(string $error = '') + { + $error = $error ?: DI::l10n()->t('Unprocessable Entity'); + $error_description = ''; + $errorobj = New \Friendica\Object\Api\Mastodon\Error($error, $error_description); + + System::jsonError(422, $errorobj->toArray()); + } + + public function Unauthorized(string $error = '') + { + $error = $error ?: DI::l10n()->t('Unauthorized'); + $error_description = ''; + $errorobj = New \Friendica\Object\Api\Mastodon\Error($error, $error_description); + + System::jsonError(401, $errorobj->toArray()); + } + + public function InternalError(string $error = '') + { + $error = $error ?: DI::l10n()->t('Internal Server Error'); + $error_description = ''; + $errorobj = New \Friendica\Object\Api\Mastodon\Error($error, $error_description); + + System::jsonError(500, $errorobj->toArray()); + } }