From 42fcb291d455ca1266efb5b17a9a486b1312d5bb Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Sun, 6 Feb 2022 18:21:03 +0400 Subject: [PATCH] feat: update error codes in the avatars API --- app/config/errors.php | 5 +++++ app/controllers/api/avatars.php | 4 ++-- src/Appwrite/Extend/Exception.php | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/config/errors.php b/app/config/errors.php index 13264fbf5c..4279b0ce2d 100644 --- a/app/config/errors.php +++ b/app/config/errors.php @@ -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 */ diff --git a/app/controllers/api/avatars.php b/app/controllers/api/avatars.php index 7b9c770ebb..c106777a36 100644 --- a/app/controllers/api/avatars.php +++ b/app/controllers/api/avatars.php @@ -317,7 +317,7 @@ App::get('/v1/avatars/favicon') $data = @\file_get_contents($outputHref, false); if (empty($data) || (\mb_substr($data, 0, 5) === '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); diff --git a/src/Appwrite/Extend/Exception.php b/src/Appwrite/Extend/Exception.php index 070e4f32ce..2c90d16805 100644 --- a/src/Appwrite/Extend/Exception.php +++ b/src/Appwrite/Extend/Exception.php @@ -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';