feat: update error codes in the accounts API
This commit is contained in:
parent
66a4c2b877
commit
fd46cdc412
|
@ -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 */
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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';
|
||||
|
|
Loading…
Reference in a new issue