]> git.mxchange.org Git - friendica.git/commitdiff
Improved error handling
authorMichael <heluecht@pirati.ca>
Wed, 12 May 2021 03:05:22 +0000 (03:05 +0000)
committerMichael <heluecht@pirati.ca>
Wed, 12 May 2021 03:05:22 +0000 (03:05 +0000)
src/Factory/Api/Mastodon/Error.php

index 2c3662288ea6363c7b06ca79a07253b7182b85e4..086cceef98e55ca31e7794deec0c30f6bc038d72 100644 (file)
@@ -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());
+       }
 }