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:21:03 +04:00
parent f6599f545e
commit 42fcb291d4
3 changed files with 8 additions and 2 deletions

View file

@ -201,6 +201,11 @@ return [
'description' => 'The remote URL could not be fetched.',
'statusCode' => 404,
],
Exception::AVATAR_ICON_NOT_FOUND => [
'name' => Exception::AVATAR_ICON_NOT_FOUND,
'description' => 'The requested favicon could not be found.',
'statusCode' => 404,
],
/** Files */

View file

@ -317,7 +317,7 @@ App::get('/v1/avatars/favicon')
$data = @\file_get_contents($outputHref, false);
if (empty($data) || (\mb_substr($data, 0, 5) === '<html') || \mb_substr($data, 0, 5) === '<!doc') {
throw new Exception('Favicon not found', 404);
throw new Exception('Favicon not found', 404, Exception::AVATAR_ICON_NOT_FOUND);
}
$cache->save($key, $data);
@ -333,7 +333,7 @@ App::get('/v1/avatars/favicon')
$fetch = @\file_get_contents($outputHref, false);
if (!$fetch) {
throw new Exception('Icon not found', 404);
throw new Exception('Icon not found', 404, Exception::AVATAR_ICON_NOT_FOUND);
}
$image = new Image($fetch);

View file

@ -58,6 +58,7 @@ class Exception extends \Exception
const AVATAR_IMAGE_NOT_FOUND = 'avatar_image_not_found';
const AVATAR_CANNOT_PARSE_IMAGE = 'avatar_cannot_parse_image';
const AVATAR_REMOTE_URL_FAILED = 'avatar_remote_url_failed';
const AVATAR_ICON_NOT_FOUND = 'avatar_icon_not_found';
/** Files */
const FILE_NOT_FOUND = 'file_not_found';