From 8e24dbe22f21b6aaae991c407dd25b7134cdf2ad Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Sun, 14 Aug 2022 13:35:11 +0530 Subject: [PATCH] feat: update exception class --- app/controllers/api/databases.php | 4 ++-- app/controllers/api/storage.php | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/controllers/api/databases.php b/app/controllers/api/databases.php index 72afb1f82c..a710a799b9 100644 --- a/app/controllers/api/databases.php +++ b/app/controllers/api/databases.php @@ -88,7 +88,7 @@ function createAttribute(string $databaseId, string $collectionId, Document $att } if ($array && $default) { - throw new Exception(Exception::ATTRIBUTE_DEFAULT_UNSUPPORTED, 'Cannot set default value for array attribute'); + throw new Exception(Exception::ATTRIBUTE_DEFAULT_UNSUPPORTED, 'Cannot set default value for array attributes'); } try { @@ -1527,7 +1527,7 @@ App::post('/v1/databases/:databaseId/collections/:collectionId/indexes') $limit = 64 - MariaDB::getNumberOfDefaultIndexes(); if ($count >= $limit) { - throw new Exception(Exception::INDEX_LIMIT_EXCEEDED, 'Index limit exceeded.'); + throw new Exception(Exception::INDEX_LIMIT_EXCEEDED, 'Index limit exceeded'); } // Convert Document[] to array of attribute metadata diff --git a/app/controllers/api/storage.php b/app/controllers/api/storage.php index 9d897b4bb1..6a361720c2 100644 --- a/app/controllers/api/storage.php +++ b/app/controllers/api/storage.php @@ -382,12 +382,12 @@ App::post('/v1/storage/buckets/:bucketId/files') if (!Auth::isAppUser($roles) && !Auth::isPrivilegedUser($roles)) { foreach ($read as $role) { if (!Authorization::isRole($role)) { - throw new Exception(Exception::USER_UNAUTHORIZED, 'Read permissions must be one of: (' . \implode(', ', $roles) . ')'); + throw new Exception(Exception::USER_UNAUTHORIZED, 'Read permissions must be one of: (' . \implode(', ', $roles) . ')', 400); } } foreach ($write as $role) { if (!Authorization::isRole($role)) { - throw new Exception(Exception::USER_UNAUTHORIZED, 'Write permissions must be one of: (' . \implode(', ', $roles) . ')'); + throw new Exception(Exception::USER_UNAUTHORIZED, 'Write permissions must be one of: (' . \implode(', ', $roles) . ')', 400); } } } @@ -1308,12 +1308,12 @@ App::put('/v1/storage/buckets/:bucketId/files/:fileId') if (!Auth::isAppUser($roles) && !Auth::isPrivilegedUser($roles)) { foreach ($read as $role) { if (!Authorization::isRole($role)) { - throw new Exception(Exception::USER_UNAUTHORIZED, 'Read permissions must be one of: (' . \implode(', ', $roles) . ')'); + throw new Exception(Exception::USER_UNAUTHORIZED, 'Read permissions must be one of: (' . \implode(', ', $roles) . ')', 400); } } foreach ($write as $role) { if (!Authorization::isRole($role)) { - throw new Exception(Exception::USER_UNAUTHORIZED, 'Write permissions must be one of: (' . \implode(', ', $roles) . ')'); + throw new Exception(Exception::USER_UNAUTHORIZED, 'Write permissions must be one of: (' . \implode(', ', $roles) . ')', 400); } } }