From 5e638f8534bd4693473ca295439e90ccc8c7f301 Mon Sep 17 00:00:00 2001 From: fogelito Date: Mon, 10 Feb 2025 08:08:29 +0200 Subject: [PATCH 1/2] IndexException --- src/Database/Database.php | 7 ++++--- src/Database/Exception/Index.php | 7 +++++++ 2 files changed, 11 insertions(+), 3 deletions(-) create mode 100644 src/Database/Exception/Index.php diff --git a/src/Database/Database.php b/src/Database/Database.php index 9ef753f13..2f9d65145 100644 --- a/src/Database/Database.php +++ b/src/Database/Database.php @@ -17,6 +17,7 @@ use Utopia\Database\Exception\Restricted as RestrictedException; use Utopia\Database\Exception\Structure as StructureException; use Utopia\Database\Exception\Timeout as TimeoutException; +use Utopia\Database\Exception\Index as IndexException; use Utopia\Database\Helpers\ID; use Utopia\Database\Helpers\Permission; use Utopia\Database\Helpers\Role; @@ -1196,7 +1197,7 @@ public function createCollection(string $id, array $attributes = [], array $inde ); foreach ($indexes as $index) { if (!$validator->isValid($index)) { - throw new DatabaseException($validator->getDescription()); + throw new IndexException($validator->getDescription()); } } } @@ -1934,7 +1935,7 @@ public function updateAttribute(string $collection, string $id, ?string $type = foreach ($indexes as $index) { if (!$validator->isValid($index)) { - throw new DatabaseException($validator->getDescription()); + throw new IndexException($validator->getDescription()); } } } @@ -2835,7 +2836,7 @@ public function createIndex(string $collection, string $id, string $type, array $this->adapter->getInternalIndexesKeys() ); if (!$validator->isValid($index)) { - throw new DatabaseException($validator->getDescription()); + throw new IndexException($validator->getDescription()); } } diff --git a/src/Database/Exception/Index.php b/src/Database/Exception/Index.php new file mode 100644 index 000000000..5e61f63bc --- /dev/null +++ b/src/Database/Exception/Index.php @@ -0,0 +1,7 @@ + Date: Mon, 10 Feb 2025 08:10:26 +0200 Subject: [PATCH 2/2] formatting --- src/Database/Database.php | 2 +- src/Database/Exception/Index.php | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Database/Database.php b/src/Database/Database.php index 2f9d65145..6e0c20b77 100644 --- a/src/Database/Database.php +++ b/src/Database/Database.php @@ -10,6 +10,7 @@ use Utopia\Database\Exception\Conflict as ConflictException; use Utopia\Database\Exception\Dependency as DependencyException; use Utopia\Database\Exception\Duplicate as DuplicateException; +use Utopia\Database\Exception\Index as IndexException; use Utopia\Database\Exception\Limit as LimitException; use Utopia\Database\Exception\NotFound as NotFoundException; use Utopia\Database\Exception\Query as QueryException; @@ -17,7 +18,6 @@ use Utopia\Database\Exception\Restricted as RestrictedException; use Utopia\Database\Exception\Structure as StructureException; use Utopia\Database\Exception\Timeout as TimeoutException; -use Utopia\Database\Exception\Index as IndexException; use Utopia\Database\Helpers\ID; use Utopia\Database\Helpers\Permission; use Utopia\Database\Helpers\Role; diff --git a/src/Database/Exception/Index.php b/src/Database/Exception/Index.php index 5e61f63bc..65524c926 100644 --- a/src/Database/Exception/Index.php +++ b/src/Database/Exception/Index.php @@ -4,4 +4,6 @@ use Utopia\Database\Exception; -class Index extends Exception {} +class Index extends Exception +{ +}