diff --git a/app/config/errors.php b/app/config/errors.php index bb861506bb..c19255776a 100644 --- a/app/config/errors.php +++ b/app/config/errors.php @@ -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 */ diff --git a/app/controllers/api/avatars.php b/app/controllers/api/avatars.php index fce98c741d..7401799425 100644 --- a/app/controllers/api/avatars.php +++ b/app/controllers/api/avatars.php @@ -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); diff --git a/src/Appwrite/Extend/Exception.php b/src/Appwrite/Extend/Exception.php index a0902f68a9..0c4a3b6d8c 100644 --- a/src/Appwrite/Extend/Exception.php +++ b/src/Appwrite/Extend/Exception.php @@ -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';