diff --git a/app/config/errors.php b/app/config/errors.php index 37dbc84271..bb861506bb 100644 --- a/app/config/errors.php +++ b/app/config/errors.php @@ -186,6 +186,11 @@ return [ 'description' => 'The Imagic extension could not be found.', 'statusCode' => 500, ], + Exception::AVATAR_IMAGE_NOT_FOUND => [ + 'name' => Exception::AVATAR_IMAGE_NOT_FOUND, + 'description' => 'The requested image was not found.', + 'statusCode' => 404, + ], /** Files */ diff --git a/app/controllers/api/avatars.php b/app/controllers/api/avatars.php index 0d79bb92b4..fce98c741d 100644 --- a/app/controllers/api/avatars.php +++ b/app/controllers/api/avatars.php @@ -169,13 +169,13 @@ App::get('/v1/avatars/image') } if (!\extension_loaded('imagick')) { - throw new Exception('Imagick extension is missing', 500); + throw new Exception('Imagick extension is missing', 500, Exception::IMAGIC_EXTENSION_MISSING); } $fetch = @\file_get_contents($url, false); if (!$fetch) { - throw new Exception('Image not found', 404); + throw new Exception('Image not found', 404, Exception::AVATAR_IMAGE_NOT_FOUND); } try { diff --git a/src/Appwrite/Extend/Exception.php b/src/Appwrite/Extend/Exception.php index e5ca2bd45f..a0902f68a9 100644 --- a/src/Appwrite/Extend/Exception.php +++ b/src/Appwrite/Extend/Exception.php @@ -55,6 +55,7 @@ class Exception extends \Exception const AVATAR_SET_NOT_FOUND = 'avatar_set_not_found'; const AVATAR_NOT_FOUND = 'avatar_not_found'; const IMAGIC_EXTENSION_MISSING = 'imagic_extension_missing'; + const AVATAR_IMAGE_NOT_FOUND = 'avatar_image_not_found'; /** Files */ const FILE_NOT_FOUND = 'file_not_found';