From 42ef7fd2d89e4c137ef48dff80ead5caa84b69ba Mon Sep 17 00:00:00 2001 From: fogelito Date: Wed, 15 Jan 2025 11:16:10 +0200 Subject: [PATCH] INDEX_DEPENDENCY --- app/config/errors.php | 5 +++++ app/controllers/general.php | 4 ++++ src/Appwrite/Extend/Exception.php | 1 + 3 files changed, 10 insertions(+) diff --git a/app/config/errors.php b/app/config/errors.php index f09d1596eb..ae1aae01c4 100644 --- a/app/config/errors.php +++ b/app/config/errors.php @@ -731,6 +731,11 @@ return [ 'description' => 'Index invalid.', 'code' => 400, ], + Exception::INDEX_DEPENDENCY => [ + 'name' => Exception::INDEX_DEPENDENCY, + 'description' => 'Attribute cannot be renamed or deleted. Please remove the associated index first.', + 'code' => 400, + ], /** Project Errors */ Exception::PROJECT_NOT_FOUND => [ diff --git a/app/controllers/general.php b/app/controllers/general.php index 6f8566f69b..7772b91c1c 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -808,6 +808,10 @@ App::error() break; case 'Utopia\Database\Exception\NotFound': $error = new AppwriteException(AppwriteException::COLLECTION_NOT_FOUND, $error->getMessage(), previous: $error); + break; + case 'Utopia\Database\Exception\Dependency': + $error = new AppwriteException(AppwriteException::INDEX_DEPENDENCY, $error->getMessage(), previous: $error); + break; } $code = $error->getCode(); diff --git a/src/Appwrite/Extend/Exception.php b/src/Appwrite/Extend/Exception.php index 54bf6d96ea..432a5abb1b 100644 --- a/src/Appwrite/Extend/Exception.php +++ b/src/Appwrite/Extend/Exception.php @@ -211,6 +211,7 @@ class Exception extends \Exception public const INDEX_LIMIT_EXCEEDED = 'index_limit_exceeded'; public const INDEX_ALREADY_EXISTS = 'index_already_exists'; public const INDEX_INVALID = 'index_invalid'; + public const INDEX_DEPENDENCY = 'index_dependency'; /** Projects */ public const PROJECT_NOT_FOUND = 'project_not_found';