feat: update error codes in the avatars API
This commit is contained in:
parent
fd46cdc412
commit
c7e1050ce5
3 changed files with 7 additions and 1 deletions
|
@ -191,6 +191,11 @@ return [
|
|||
'description' => 'The requested image was not found.',
|
||||
'statusCode' => 404,
|
||||
],
|
||||
Exception::AVATAR_CANNOT_PARSE_IMAGE => [
|
||||
'name' => Exception::AVATAR_CANNOT_PARSE_IMAGE,
|
||||
'description' => 'The requested image could not be parsed.',
|
||||
'statusCode' => 500,
|
||||
],
|
||||
|
||||
|
||||
/** Files */
|
||||
|
|
|
@ -181,7 +181,7 @@ App::get('/v1/avatars/image')
|
|||
try {
|
||||
$image = new Image($fetch);
|
||||
} catch (\Exception$exception) {
|
||||
throw new Exception('Unable to parse image', 500);
|
||||
throw new Exception('Unable to parse image', 500, Exception::AVATAR_CANNOT_PARSE_IMAGE);
|
||||
}
|
||||
|
||||
$image->crop((int) $width, (int) $height);
|
||||
|
|
|
@ -56,6 +56,7 @@ class Exception extends \Exception
|
|||
const AVATAR_NOT_FOUND = 'avatar_not_found';
|
||||
const IMAGIC_EXTENSION_MISSING = 'imagic_extension_missing';
|
||||
const AVATAR_IMAGE_NOT_FOUND = 'avatar_image_not_found';
|
||||
const AVATAR_CANNOT_PARSE_IMAGE = 'avatar_cannot_parse_image';
|
||||
|
||||
/** Files */
|
||||
const FILE_NOT_FOUND = 'file_not_found';
|
||||
|
|
Loading…
Reference in a new issue