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

feat: update error codes in the accounts API

This commit is contained in:
Christy Jacob 2022-02-06 18:16:14 +04:00
parent 66a4c2b877
commit fd46cdc412
3 changed files with 8 additions and 2 deletions

View file

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

View file

@ -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 {

View file

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