feat: handle utopia exceptions
This commit is contained in:
parent
847abadd39
commit
44f7d85a64
|
@ -387,6 +387,13 @@ App::error(function ($error, $utopia, $request, $response, $layout, $project, $l
|
||||||
throw $error;
|
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;
|
$template = ($route) ? $route->getLabel('error', null) : null;
|
||||||
|
|
||||||
if (php_sapi_name() === 'cli') {
|
if (php_sapi_name() === 'cli') {
|
||||||
|
|
|
@ -151,6 +151,7 @@ class Exception extends \Exception
|
||||||
const GENERAL_UNAUTHORIZED_SCOPE = 'general_unauthorized_scope';
|
const GENERAL_UNAUTHORIZED_SCOPE = 'general_unauthorized_scope';
|
||||||
const GENERAL_RATE_LIMIT_EXCEEDED = 'general_rate_limit_exceeded';
|
const GENERAL_RATE_LIMIT_EXCEEDED = 'general_rate_limit_exceeded';
|
||||||
const GENERAL_SMTP_DISABLED = 'general_smtp_disabled';
|
const GENERAL_SMTP_DISABLED = 'general_smtp_disabled';
|
||||||
|
const GENERAL_ARGUMENT_INVALID = 'general_argument_invalid';
|
||||||
const GENERAL_SERVER_ERROR = 'general_server_error';
|
const GENERAL_SERVER_ERROR = 'general_server_error';
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue