1
0
Fork 0
mirror of synced 2024-06-17 10:14:50 +12:00

feat: handle utopia exceptions

This commit is contained in:
Christy Jacob 2022-02-07 02:55:53 +04:00
parent 847abadd39
commit 44f7d85a64
2 changed files with 8 additions and 0 deletions

View file

@ -387,6 +387,13 @@ App::error(function ($error, $utopia, $request, $response, $layout, $project, $l
throw $error;
}
/** Wrap all exceptions inside Appwrite\Extend\Exception */
if ($error instanceof Utopia\Exception && $error->getCode() === 400) {
$error = new Exception($error->getMessage(), $error->getCode(), Exception::GENERAL_ARGUMENT_INVALID, $error);
} else {
$error = new Exception($error->getMessage(), $error->getCode(), Exception::GENERAL_DEFAULT, $error);
}
$template = ($route) ? $route->getLabel('error', null) : null;
if (php_sapi_name() === 'cli') {

View file

@ -151,6 +151,7 @@ class Exception extends \Exception
const GENERAL_UNAUTHORIZED_SCOPE = 'general_unauthorized_scope';
const GENERAL_RATE_LIMIT_EXCEEDED = 'general_rate_limit_exceeded';
const GENERAL_SMTP_DISABLED = 'general_smtp_disabled';
const GENERAL_ARGUMENT_INVALID = 'general_argument_invalid';
const GENERAL_SERVER_ERROR = 'general_server_error';