1
0
Fork 0
mirror of synced 2024-06-02 10:54:44 +12:00

feat: update cursor errors

This commit is contained in:
Christy Jacob 2022-02-09 03:08:23 +04:00
parent 1ab27083c4
commit cb922827a4
2 changed files with 20 additions and 3 deletions

View file

@ -376,11 +376,13 @@ App::error(function ($error, $utopia, $request, $response, $layout, $project, $l
}
/** 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 {
if (!($error instanceof Exception)) {
$error = new Exception($error->getMessage(), $error->getCode(), Exception::GENERAL_UNKNOWN, $error);
}
if ($error instanceof Utopia\Exception && $error->getCode() === 400) {
$error->setType(Exception::GENERAL_ARGUMENT_INVALID);
}
$template = ($route) ? $route->getLabel('error', null) : null;

View file

@ -159,10 +159,25 @@ class Exception extends \Exception
}
/**
* Get the type of the exception.
*
* @return string
*/
public function getType(): string
{
return $this->type;
}
/**
* Set the type of the exception.
*
* @param string $type
*
* @return void
*/
public function setType(string $type): void
{
$this->type = $type;
}
}