1
0
Fork 0
mirror of synced 2024-06-26 18:20:43 +12:00

feat: update error codes in the avatars API

This commit is contained in:
Christy Jacob 2022-02-06 18:17:26 +04:00
parent fd46cdc412
commit c7e1050ce5
3 changed files with 7 additions and 1 deletions

View file

@ -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 */

View file

@ -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);

View file

@ -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';