diff --git a/src/Appwrite/Extend/Exception.php b/src/Appwrite/Extend/Exception.php index 27d2f62059..33c0942b2d 100644 --- a/src/Appwrite/Extend/Exception.php +++ b/src/Appwrite/Extend/Exception.php @@ -389,7 +389,8 @@ class Exception extends \Exception string $message = null, int|string $code = null, \Throwable $previous = null, - ?string $view = null + ?string $view = null, + array $params = [] ) { $this->errors = Config::getParam('errors'); $this->type = $type; @@ -405,30 +406,19 @@ class Exception extends \Exception } } - $this->message = $message ?? $this->errors[$type]['description']; + // Format message with params if provided + if (!empty($params) && $message === null) { + $description = $this->errors[$type]['description'] ?? ''; + $this->message = !empty($description) ? sprintf($description, ...$params) : ''; + } else { + $this->message = $message ?? $this->errors[$type]['description']; + } $this->publish = $this->errors[$type]['publish'] ?? ($this->code >= 500); parent::__construct($this->message, $this->code, $previous); } - /** - * Create an exception with formatted parameters. - */ - public static function withParams(string $type, mixed ...$params): self - { - $errors = Config::getParam('errors'); - $description = $errors[$type]['description'] ?? ''; - - if (!empty($params) && !empty($description)) { - $message = sprintf($description, ...$params); - } else { - $message = $description; - } - - return new self($type, $message); - } - /** * Get the type of the exception. * diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Action.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Action.php index 3156d87b7f..83a401a35e 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Action.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Action.php @@ -307,19 +307,19 @@ abstract class Action extends UtopiaAction $options = $attribute->getAttribute('options', []); if (in_array($type, Database::SPATIAL_TYPES) && !$dbForProject->getAdapter()->getSupportForSpatialAttributes()) { - throw Exception::withParams($this->getSpatialTypeNotSupportedException(), $type); + throw new Exception($this->getSpatialTypeNotSupportedException(), params: [$type]); } $db = Authorization::skip(fn () => $dbForProject->getDocument('databases', $databaseId)); if ($db->isEmpty()) { - throw Exception::withParams(Exception::DATABASE_NOT_FOUND, $databaseId); + throw new Exception(Exception::DATABASE_NOT_FOUND, params: [$databaseId]); } $collection = $dbForProject->getDocument('database_' . $db->getSequence(), $collectionId); if ($collection->isEmpty()) { - throw Exception::withParams($this->getParentNotFoundException(), $collectionId); + throw new Exception($this->getParentNotFoundException(), params: [$collectionId]); } if (!empty($format)) { @@ -382,9 +382,9 @@ abstract class Action extends UtopiaAction $dbForProject->checkAttribute($collection, $attribute); $attribute = $dbForProject->createDocument('attributes', $attribute); } catch (DuplicateException) { - throw Exception::withParams($this->getDuplicateException(), $key); + throw new Exception($this->getDuplicateException(), params: [$key]); } catch (LimitException) { - throw Exception::withParams($this->getLimitException(), $collectionId); + throw new Exception($this->getLimitException(), params: [$collectionId]); } catch (StructureException $e) { throw new Exception($this->getStructureException(), $e->getMessage()); } catch (Throwable $e) { @@ -426,9 +426,9 @@ abstract class Action extends UtopiaAction $dbForProject->checkAttribute($relatedCollection, $twoWayAttribute); $dbForProject->createDocument('attributes', $twoWayAttribute); } catch (DuplicateException) { - throw Exception::withParams($this->getDuplicateException(), $twoWayKey); + throw new Exception($this->getDuplicateException(), params: [$twoWayKey]); } catch (LimitException) { - throw Exception::withParams($this->getLimitException(), $relatedCollection->getId()); + throw new Exception($this->getLimitException(), params: [$relatedCollection->getId()]); } catch (StructureException) { throw new Exception($this->getStructureException()); } catch (Throwable $e) { @@ -477,19 +477,19 @@ abstract class Action extends UtopiaAction $db = Authorization::skip(fn () => $dbForProject->getDocument('databases', $databaseId)); if ($db->isEmpty()) { - throw Exception::withParams(Exception::DATABASE_NOT_FOUND, $databaseId); + throw new Exception(Exception::DATABASE_NOT_FOUND, params: [$databaseId]); } $collection = $dbForProject->getDocument('database_' . $db->getSequence(), $collectionId); if ($collection->isEmpty()) { - throw Exception::withParams($this->getParentNotFoundException(), $collectionId); + throw new Exception($this->getParentNotFoundException(), params: [$collectionId]); } $attribute = $dbForProject->getDocument('attributes', $db->getSequence() . '_' . $collection->getSequence() . '_' . $key); if ($attribute->isEmpty()) { - throw Exception::withParams($this->getNotFoundException(), $key); + throw new Exception($this->getNotFoundException(), params: [$key]); } if ($attribute->getAttribute('status') !== 'available') { @@ -590,7 +590,7 @@ abstract class Action extends UtopiaAction } catch (IndexException) { throw new Exception(Exception::INDEX_INVALID); } catch (LimitException) { - throw Exception::withParams($this->getLimitException(), $collectionId); + throw new Exception($this->getLimitException(), params: [$collectionId]); } catch (RelationshipException $e) { throw new Exception(Exception::RELATIONSHIP_VALUE_INVALID, $e->getMessage()); } catch (StructureException $e) { @@ -624,11 +624,11 @@ abstract class Action extends UtopiaAction newKey: $newKey ?? null ); } catch (DuplicateException) { - throw Exception::withParams($this->getDuplicateException(), $key); + throw new Exception($this->getDuplicateException(), params: [$key]); } catch (IndexException $e) { throw new Exception($this->getInvalidIndexException(), $e->getMessage()); } catch (LimitException) { - throw Exception::withParams($this->getLimitException(), $collectionId); + throw new Exception($this->getLimitException(), params: [$collectionId]); } catch (TruncateException) { throw new Exception($this->getInvalidResizeException()); } @@ -644,7 +644,7 @@ abstract class Action extends UtopiaAction try { $dbForProject->updateDocument('attributes', $originalUid, $attribute); } catch (DuplicateException) { - throw Exception::withParams($this->getDuplicateException(), $newKey); + throw new Exception($this->getDuplicateException(), params: [$newKey]); } /** diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Delete.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Delete.php index eff1dfe781..23c21fecee 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Delete.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Delete.php @@ -74,17 +74,17 @@ class Delete extends Action { $db = Authorization::skip(fn () => $dbForProject->getDocument('databases', $databaseId)); if ($db->isEmpty()) { - throw Exception::withParams(Exception::DATABASE_NOT_FOUND, $databaseId); + throw new Exception(Exception::DATABASE_NOT_FOUND, params: [$databaseId]); } $collection = $dbForProject->getDocument('database_' . $db->getSequence(), $collectionId); if ($collection->isEmpty()) { - throw Exception::withParams($this->getParentNotFoundException(), $collectionId); + throw new Exception($this->getParentNotFoundException(), params: [$collectionId]); } $attribute = $dbForProject->getDocument('attributes', $db->getSequence() . '_' . $collection->getSequence() . '_' . $key); if ($attribute->isEmpty()) { - throw Exception::withParams($this->getNotFoundException(), $key); + throw new Exception($this->getNotFoundException(), params: [$key]); } $validator = new IndexDependencyValidator( @@ -93,7 +93,7 @@ class Delete extends Action ); if (!$validator->isValid($attribute)) { - throw Exception::withParams($this->getIndexDependencyException(), $key); + throw new Exception($this->getIndexDependencyException(), params: [$key]); } if ($attribute->getAttribute('status') === 'available') { @@ -108,12 +108,12 @@ class Delete extends Action if ($options['twoWay']) { $relatedCollection = $dbForProject->getDocument('database_' . $db->getSequence(), $options['relatedCollection']); if ($relatedCollection->isEmpty()) { - throw Exception::withParams($this->getParentNotFoundException(), $options['relatedCollection']); + throw new Exception($this->getParentNotFoundException(), params: [$options['relatedCollection']]); } $relatedAttribute = $dbForProject->getDocument('attributes', $db->getSequence() . '_' . $relatedCollection->getSequence() . '_' . $options['twoWayKey']); if ($relatedAttribute->isEmpty()) { - throw Exception::withParams($this->getNotFoundException(), $options['twoWayKey']); + throw new Exception($this->getNotFoundException(), params: [$options['twoWayKey']]); } if ($relatedAttribute->getAttribute('status') === 'available') { diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Get.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Get.php index f0ee593a51..c11dd1c63b 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Get.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Get.php @@ -75,17 +75,17 @@ class Get extends Action { $database = Authorization::skip(fn () => $dbForProject->getDocument('databases', $databaseId)); if ($database->isEmpty()) { - throw Exception::withParams(Exception::DATABASE_NOT_FOUND, $databaseId); + throw new Exception(Exception::DATABASE_NOT_FOUND, params: [$databaseId]); } $collection = $dbForProject->getDocument('database_' . $database->getSequence(), $collectionId); if ($collection->isEmpty()) { - throw Exception::withParams($this->getParentNotFoundException(), $collectionId); + throw new Exception($this->getParentNotFoundException(), params: [$collectionId]); } $attribute = $dbForProject->getDocument('attributes', $database->getSequence() . '_' . $collection->getSequence() . '_' . $key); if ($attribute->isEmpty()) { - throw Exception::withParams($this->getNotFoundException(), $key); + throw new Exception($this->getNotFoundException(), params: [$key]); } $type = $attribute->getAttribute('type'); diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Relationship/Create.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Relationship/Create.php index ecfa284c27..5606c63a08 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Relationship/Create.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Relationship/Create.php @@ -93,19 +93,19 @@ class Create extends Action $database = Authorization::skip(fn () => $dbForProject->getDocument('databases', $databaseId)); if ($database->isEmpty()) { - throw Exception::withParams(Exception::DATABASE_NOT_FOUND, $databaseId); + throw new Exception(Exception::DATABASE_NOT_FOUND, params: [$databaseId]); } $collection = $dbForProject->getDocument('database_' . $database->getSequence(), $collectionId); $collection = $dbForProject->getCollection('database_' . $database->getSequence() . '_collection_' . $collection->getSequence()); if ($collection->isEmpty()) { - throw Exception::withParams($this->getParentNotFoundException(), $collectionId); + throw new Exception($this->getParentNotFoundException(), params: [$collectionId]); } $relatedCollectionDocument = $dbForProject->getDocument('database_' . $database->getSequence(), $relatedCollectionId); $relatedCollection = $dbForProject->getCollection('database_' . $database->getSequence() . '_collection_' . $relatedCollectionDocument->getSequence()); if ($relatedCollection->isEmpty()) { - throw Exception::withParams($this->getParentNotFoundException(), $relatedCollectionId); + throw new Exception($this->getParentNotFoundException(), params: [$relatedCollectionId]); } $attributes = $collection->getAttribute('attributes', []); @@ -115,14 +115,14 @@ class Create extends Action } if (\strtolower($attribute->getId()) === \strtolower($key)) { - throw Exception::withParams($this->getDuplicateException(), $key); + throw new Exception($this->getDuplicateException(), params: [$key]); } if ( \strtolower($attribute->getAttribute('options')['twoWayKey']) === \strtolower($twoWayKey) && $attribute->getAttribute('options')['relatedCollection'] === $relatedCollection->getId() ) { - throw Exception::withParams($this->getDuplicateException(), $twoWayKey); + throw new Exception($this->getDuplicateException(), params: [$twoWayKey]); } if ( diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/XList.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/XList.php index 2279500bca..065cb333db 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/XList.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/XList.php @@ -71,12 +71,12 @@ class XList extends Action { $database = Authorization::skip(fn () => $dbForProject->getDocument('databases', $databaseId)); if ($database->isEmpty()) { - throw Exception::withParams(Exception::DATABASE_NOT_FOUND, $databaseId); + throw new Exception(Exception::DATABASE_NOT_FOUND, params: [$databaseId]); } $collection = $dbForProject->getDocument('database_' . $database->getSequence(), $collectionId); if ($collection->isEmpty()) { - throw Exception::withParams($this->getParentNotFoundException(), $collectionId); + throw new Exception($this->getParentNotFoundException(), params: [$collectionId]); } try { diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Create.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Create.php index 8e23136394..d285c1ac13 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Create.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Create.php @@ -93,7 +93,7 @@ class Create extends Action $database = Authorization::skip(fn () => $dbForProject->getDocument('databases', $databaseId)); if ($database->isEmpty()) { - throw Exception::withParams(Exception::DATABASE_NOT_FOUND, $databaseId); + throw new Exception(Exception::DATABASE_NOT_FOUND, params: [$databaseId]); } $collectionId = $collectionId === 'unique()' ? ID::unique() : $collectionId; @@ -113,11 +113,11 @@ class Create extends Action 'search' => \implode(' ', [$collectionId, $name]), ])); } catch (DuplicateException) { - throw Exception::withParams($this->getDuplicateException(), $collectionId); + throw new Exception($this->getDuplicateException(), params: [$collectionId]); } catch (LimitException) { - throw Exception::withParams($this->getLimitException(), $databaseId); + throw new Exception($this->getLimitException(), params: [$databaseId]); } catch (NotFoundException) { - throw Exception::withParams(Exception::DATABASE_NOT_FOUND, $databaseId); + throw new Exception(Exception::DATABASE_NOT_FOUND, params: [$databaseId]); } $collectionKey = 'database_' . $database->getSequence() . '_collection_' . $collection->getSequence(); @@ -205,13 +205,13 @@ class Create extends Action ); } catch (DuplicateException) { $dbForProject->deleteDocument($databaseKey, $collection->getId()); - throw Exception::withParams($this->getDuplicateException(), $collectionId); + throw new Exception($this->getDuplicateException(), params: [$collectionId]); } catch (IndexException $e) { $dbForProject->deleteDocument($databaseKey, $collection->getId()); throw new Exception($this->getInvalidIndexException(), $e->getMessage()); } catch (LimitException) { $dbForProject->deleteDocument($databaseKey, $collection->getId()); - throw Exception::withParams($this->getLimitException(), $collectionId); + throw new Exception($this->getLimitException(), params: [$collectionId]); } catch (\Throwable $e) { $dbForProject->deleteDocument($databaseKey, $collection->getId()); throw $e; @@ -227,7 +227,7 @@ class Create extends Action } } catch (DuplicateException) { $this->cleanup($dbForProject, $databaseKey, $collectionKey, $collection->getId()); - throw Exception::withParams($this->getDuplicateException(), $collectionId); + throw new Exception($this->getDuplicateException(), params: [$collectionId]); } catch (\Throwable $e) { $this->cleanup($dbForProject, $databaseKey, $collectionKey, $collection->getId()); throw $e; diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Delete.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Delete.php index a43e4dc687..bf0f83bb11 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Delete.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Delete.php @@ -71,12 +71,12 @@ class Delete extends Action { $database = Authorization::skip(fn () => $dbForProject->getDocument('databases', $databaseId)); if ($database->isEmpty()) { - throw Exception::withParams(Exception::DATABASE_NOT_FOUND, $databaseId); + throw new Exception(Exception::DATABASE_NOT_FOUND, params: [$databaseId]); } $collection = $dbForProject->getDocument('database_' . $database->getSequence(), $collectionId); if ($collection->isEmpty()) { - throw Exception::withParams($this->getNotFoundException(), $collectionId); + throw new Exception($this->getNotFoundException(), params: [$collectionId]); } if (!$dbForProject->deleteDocument('database_' . $database->getSequence(), $collectionId)) { diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Attribute/Decrement.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Attribute/Decrement.php index daa3f92e7b..38e7f8f231 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Attribute/Decrement.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Attribute/Decrement.php @@ -95,12 +95,12 @@ class Decrement extends Action $database = Authorization::skip(fn () => $dbForProject->getDocument('databases', $databaseId)); if ($database->isEmpty()) { - throw Exception::withParams(Exception::DATABASE_NOT_FOUND, $databaseId); + throw new Exception(Exception::DATABASE_NOT_FOUND, params: [$databaseId]); } $collection = Authorization::skip(fn () => $dbForProject->getDocument('database_' . $database->getSequence(), $collectionId)); if ($collection->isEmpty()) { - throw Exception::withParams($this->getParentNotFoundException(), $collectionId); + throw new Exception($this->getParentNotFoundException(), params: [$collectionId]); } // Handle transaction staging diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Attribute/Increment.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Attribute/Increment.php index 544e9f233d..10dadae824 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Attribute/Increment.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Attribute/Increment.php @@ -95,12 +95,12 @@ class Increment extends Action $database = Authorization::skip(fn () => $dbForProject->getDocument('databases', $databaseId)); if ($database->isEmpty()) { - throw Exception::withParams(Exception::DATABASE_NOT_FOUND, $databaseId); + throw new Exception(Exception::DATABASE_NOT_FOUND, params: [$databaseId]); } $collection = Authorization::skip(fn () => $dbForProject->getDocument('database_' . $database->getSequence(), $collectionId)); if ($collection->isEmpty()) { - throw Exception::withParams($this->getParentNotFoundException(), $collectionId); + throw new Exception($this->getParentNotFoundException(), params: [$collectionId]); } // Handle transaction staging diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Bulk/Delete.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Bulk/Delete.php index f9af8af9e3..070ee09450 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Bulk/Delete.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Bulk/Delete.php @@ -88,12 +88,12 @@ class Delete extends Action { $database = $dbForProject->getDocument('databases', $databaseId); if ($database->isEmpty()) { - throw Exception::withParams(Exception::DATABASE_NOT_FOUND, $databaseId); + throw new Exception(Exception::DATABASE_NOT_FOUND, params: [$databaseId]); } $collection = $dbForProject->getDocument('database_' . $database->getSequence(), $collectionId); if ($collection->isEmpty()) { - throw Exception::withParams($this->getParentNotFoundException(), $collectionId); + throw new Exception($this->getParentNotFoundException(), params: [$collectionId]); } $hasRelationships = \array_filter( diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Bulk/Update.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Bulk/Update.php index ef065da1f8..2d55cd54f4 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Bulk/Update.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Bulk/Update.php @@ -100,12 +100,12 @@ class Update extends Action $database = $dbForProject->getDocument('databases', $databaseId); if ($database->isEmpty()) { - throw Exception::withParams(Exception::DATABASE_NOT_FOUND, $databaseId); + throw new Exception(Exception::DATABASE_NOT_FOUND, params: [$databaseId]); } $collection = $dbForProject->getDocument('database_' . $database->getSequence(), $collectionId); if ($collection->isEmpty()) { - throw Exception::withParams($this->getParentNotFoundException(), $collectionId); + throw new Exception($this->getParentNotFoundException(), params: [$collectionId]); } if ($transactionId === null) { diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Bulk/Upsert.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Bulk/Upsert.php index b80694d4f2..45db6cc96b 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Bulk/Upsert.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Bulk/Upsert.php @@ -90,12 +90,12 @@ class Upsert extends Action { $database = $dbForProject->getDocument('databases', $databaseId); if ($database->isEmpty()) { - throw Exception::withParams(Exception::DATABASE_NOT_FOUND, $databaseId); + throw new Exception(Exception::DATABASE_NOT_FOUND, params: [$databaseId]); } $collection = $dbForProject->getDocument('database_' . $database->getSequence(), $collectionId); if ($collection->isEmpty()) { - throw Exception::withParams($this->getParentNotFoundException(), $collectionId); + throw new Exception($this->getParentNotFoundException(), params: [$collectionId]); } $hasRelationships = \array_filter( @@ -180,7 +180,7 @@ class Upsert extends Action } catch (ConflictException) { throw new Exception($this->getConflictException()); } catch (DuplicateException) { - throw Exception::withParams($this->getDuplicateException(), 'multiple'); + throw new Exception($this->getDuplicateException(), params: ['multiple']); } catch (RelationshipException $e) { throw new Exception(Exception::RELATIONSHIP_VALUE_INVALID, $e->getMessage()); } catch (StructureException $e) { diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Create.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Create.php index f38df32b30..a7fb81a486 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Create.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Create.php @@ -187,12 +187,12 @@ class Create extends Action $database = Authorization::skip(fn () => $dbForProject->getDocument('databases', $databaseId)); if ($database->isEmpty() || (!$database->getAttribute('enabled', false) && !$isAPIKey && !$isPrivilegedUser)) { - throw Exception::withParams(Exception::DATABASE_NOT_FOUND, $databaseId); + throw new Exception(Exception::DATABASE_NOT_FOUND, params: [$databaseId]); } $collection = Authorization::skip(fn () => $dbForProject->getDocument('database_' . $database->getSequence(), $collectionId)); if ($collection->isEmpty() || (!$collection->getAttribute('enabled', false) && !$isAPIKey && !$isPrivilegedUser)) { - throw Exception::withParams($this->getParentNotFoundException(), $collectionId); + throw new Exception($this->getParentNotFoundException(), params: [$collectionId]); } $hasRelationships = \array_filter( @@ -372,7 +372,7 @@ class Create extends Action ? Authorization::skip(fn () => $dbForProject->getDocument('transactions', $transactionId)) : $dbForProject->getDocument('transactions', $transactionId); if ($transaction->isEmpty()) { - throw Exception::withParams(Exception::TRANSACTION_NOT_FOUND, $transactionId); + throw new Exception(Exception::TRANSACTION_NOT_FOUND, params: [$transactionId]); } if ($transaction->getAttribute('status', '') !== 'pending') { throw new Exception(Exception::TRANSACTION_NOT_READY); @@ -444,9 +444,9 @@ class Create extends Action ) ); } catch (DuplicateException) { - throw Exception::withParams($this->getDuplicateException(), $documentId); + throw new Exception($this->getDuplicateException(), params: [$documentId]); } catch (NotFoundException) { - throw Exception::withParams($this->getParentNotFoundException(), $collectionId); + throw new Exception($this->getParentNotFoundException(), params: [$collectionId]); } catch (RelationshipException $e) { throw new Exception(Exception::RELATIONSHIP_VALUE_INVALID, $e->getMessage()); } catch (StructureException $e) { diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Delete.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Delete.php index c83510ed29..14a51c0fac 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Delete.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Delete.php @@ -105,13 +105,13 @@ class Delete extends Action $isPrivilegedUser = User::isPrivileged(Authorization::getRoles()); if ($database->isEmpty() || (!$database->getAttribute('enabled', false) && !$isAPIKey && !$isPrivilegedUser)) { - throw Exception::withParams(Exception::DATABASE_NOT_FOUND, $databaseId); + throw new Exception(Exception::DATABASE_NOT_FOUND, params: [$databaseId]); } $collection = Authorization::skip(fn () => $dbForProject->getDocument('database_' . $database->getSequence(), $collectionId)); if ($collection->isEmpty() || (!$collection->getAttribute('enabled', false) && !$isAPIKey && !$isPrivilegedUser)) { - throw Exception::withParams($this->getParentNotFoundException(), $collectionId); + throw new Exception($this->getParentNotFoundException(), params: [$collectionId]); } // Read permission should not be required for delete @@ -125,7 +125,7 @@ class Delete extends Action } if ($document->isEmpty()) { - throw Exception::withParams($this->getNotFoundException(), $documentId); + throw new Exception($this->getNotFoundException(), params: [$documentId]); } // Handle transaction staging @@ -134,7 +134,7 @@ class Delete extends Action ? Authorization::skip(fn () => $dbForProject->getDocument('transactions', $transactionId)) : $dbForProject->getDocument('transactions', $transactionId); if ($transaction->isEmpty()) { - throw Exception::withParams(Exception::TRANSACTION_NOT_FOUND, $transactionId); + throw new Exception(Exception::TRANSACTION_NOT_FOUND, params: [$transactionId]); } if ($transaction->getAttribute('status', '') !== 'pending') { throw new Exception(Exception::TRANSACTION_NOT_READY); diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Get.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Get.php index 8e80f1ddb1..62919488e6 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Get.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Get.php @@ -80,13 +80,13 @@ class Get extends Action $database = Authorization::skip(fn () => $dbForProject->getDocument('databases', $databaseId)); if ($database->isEmpty() || (!$database->getAttribute('enabled', false) && !$isAPIKey && !$isPrivilegedUser)) { - throw Exception::withParams(Exception::DATABASE_NOT_FOUND, $databaseId); + throw new Exception(Exception::DATABASE_NOT_FOUND, params: [$databaseId]); } $collection = Authorization::skip(fn () => $dbForProject->getDocument('database_' . $database->getSequence(), $collectionId)); if ($collection->isEmpty() || (!$collection->getAttribute('enabled', false) && !$isAPIKey && !$isPrivilegedUser)) { - throw Exception::withParams($this->getParentNotFoundException(), $collectionId); + throw new Exception($this->getParentNotFoundException(), params: [$collectionId]); } try { @@ -114,7 +114,7 @@ class Get extends Action } if ($document->isEmpty()) { - throw Exception::withParams($this->getNotFoundException(), $documentId); + throw new Exception($this->getNotFoundException(), params: [$documentId]); } $operations = 0; diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Logs/XList.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Logs/XList.php index 7b1447f3c3..47f5247831 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Logs/XList.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Logs/XList.php @@ -79,17 +79,17 @@ class XList extends Action { $database = Authorization::skip(fn () => $dbForProject->getDocument('databases', $databaseId)); if ($database->isEmpty()) { - throw Exception::withParams(Exception::DATABASE_NOT_FOUND, $databaseId); + throw new Exception(Exception::DATABASE_NOT_FOUND, params: [$databaseId]); } $collection = $dbForProject->getDocument('database_' . $database->getSequence(), $collectionId); if ($collection->isEmpty()) { - throw Exception::withParams($this->getParentNotFoundException(), $collectionId); + throw new Exception($this->getParentNotFoundException(), params: [$collectionId]); } $document = $dbForProject->getDocument('database_' . $database->getSequence() . '_collection_' . $collection->getSequence(), $documentId); if ($document->isEmpty()) { - throw Exception::withParams($this->getNotFoundException(), $documentId); + throw new Exception($this->getNotFoundException(), params: [$documentId]); } try { diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Update.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Update.php index 165f256941..d2b67665a7 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Update.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Update.php @@ -104,13 +104,13 @@ class Update extends Action $isPrivilegedUser = User::isPrivileged(Authorization::getRoles()); if ($database->isEmpty() || (!$database->getAttribute('enabled', false) && !$isAPIKey && !$isPrivilegedUser)) { - throw Exception::withParams(Exception::DATABASE_NOT_FOUND, $databaseId); + throw new Exception(Exception::DATABASE_NOT_FOUND, params: [$databaseId]); } $collection = Authorization::skip(fn () => $dbForProject->getDocument('database_' . $database->getSequence(), $collectionId)); if ($collection->isEmpty() || (!$collection->getAttribute('enabled', false) && !$isAPIKey && !$isPrivilegedUser)) { - throw Exception::withParams($this->getParentNotFoundException(), $collectionId); + throw new Exception($this->getParentNotFoundException(), params: [$collectionId]); } if ($transactionId === null) { @@ -129,7 +129,7 @@ class Update extends Action } if ($document->isEmpty()) { - throw Exception::withParams($this->getNotFoundException(), $documentId); + throw new Exception($this->getNotFoundException(), params: [$documentId]); } // Map aggregate permissions into the multiple permissions they represent. @@ -252,7 +252,7 @@ class Update extends Action ? Authorization::skip(fn () => $dbForProject->getDocument('transactions', $transactionId)) : $dbForProject->getDocument('transactions', $transactionId); if ($transaction->isEmpty()) { - throw Exception::withParams(Exception::TRANSACTION_NOT_FOUND, $transactionId); + throw new Exception(Exception::TRANSACTION_NOT_FOUND, params: [$transactionId]); } if ($transaction->getAttribute('status', '') !== 'pending') { throw new Exception(Exception::TRANSACTION_NOT_READY); @@ -326,7 +326,7 @@ class Update extends Action } catch (ConflictException) { throw new Exception($this->getConflictException()); } catch (DuplicateException) { - throw Exception::withParams($this->getDuplicateException(), $documentId); + throw new Exception($this->getDuplicateException(), params: [$documentId]); } catch (RelationshipException $e) { throw new Exception(Exception::RELATIONSHIP_VALUE_INVALID, $e->getMessage()); } catch (StructureException $e) { diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Upsert.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Upsert.php index 7ff78bf913..d85fb17842 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Upsert.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Upsert.php @@ -111,12 +111,12 @@ class Upsert extends Action $database = Authorization::skip(fn () => $dbForProject->getDocument('databases', $databaseId)); if ($database->isEmpty() || (!$database->getAttribute('enabled', false) && !$isAPIKey && !$isPrivilegedUser)) { - throw Exception::withParams(Exception::DATABASE_NOT_FOUND, $databaseId); + throw new Exception(Exception::DATABASE_NOT_FOUND, params: [$databaseId]); } $collection = Authorization::skip(fn () => $dbForProject->getDocument('database_' . $database->getSequence(), $collectionId)); if ($collection->isEmpty() || (!$collection->getAttribute('enabled', false) && !$isAPIKey && !$isPrivilegedUser)) { - throw Exception::withParams($this->getParentNotFoundException(), $collectionId); + throw new Exception($this->getParentNotFoundException(), params: [$collectionId]); } if ($transactionId === null) { @@ -262,7 +262,7 @@ class Upsert extends Action ? Authorization::skip(fn () => $dbForProject->getDocument('transactions', $transactionId)) : $dbForProject->getDocument('transactions', $transactionId); if ($transaction->isEmpty()) { - throw Exception::withParams(Exception::TRANSACTION_NOT_FOUND, $transactionId); + throw new Exception(Exception::TRANSACTION_NOT_FOUND, params: [$transactionId]); } if ($transaction->getAttribute('status', '') !== 'pending') { throw new Exception(Exception::TRANSACTION_NOT_READY); @@ -335,7 +335,7 @@ class Upsert extends Action } catch (ConflictException) { throw new Exception($this->getConflictException()); } catch (DuplicateException) { - throw Exception::withParams($this->getDuplicateException(), $documentId); + throw new Exception($this->getDuplicateException(), params: [$documentId]); } catch (RelationshipException $e) { throw new Exception(Exception::RELATIONSHIP_VALUE_INVALID, $e->getMessage()); } catch (StructureException $e) { diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/XList.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/XList.php index 43f56d694e..b14a4f9983 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/XList.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/XList.php @@ -84,12 +84,12 @@ class XList extends Action $database = Authorization::skip(fn () => $dbForProject->getDocument('databases', $databaseId)); if ($database->isEmpty() || (!$database->getAttribute('enabled', false) && !$isAPIKey && !$isPrivilegedUser)) { - throw Exception::withParams(Exception::DATABASE_NOT_FOUND, $databaseId); + throw new Exception(Exception::DATABASE_NOT_FOUND, params: [$databaseId]); } $collection = Authorization::skip(fn () => $dbForProject->getDocument('database_' . $database->getSequence(), $collectionId)); if ($collection->isEmpty() || (!$collection->getAttribute('enabled', false) && !$isAPIKey && !$isPrivilegedUser)) { - throw Exception::withParams($this->getParentNotFoundException(), $collectionId); + throw new Exception($this->getParentNotFoundException(), params: [$collectionId]); } try { diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Get.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Get.php index 1ff71110bf..22d1333cc4 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Get.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Get.php @@ -65,13 +65,13 @@ class Get extends Action $database = Authorization::skip(fn () => $dbForProject->getDocument('databases', $databaseId)); if ($database->isEmpty()) { - throw Exception::withParams(Exception::DATABASE_NOT_FOUND, $databaseId); + throw new Exception(Exception::DATABASE_NOT_FOUND, params: [$databaseId]); } $collection = $dbForProject->getDocument('database_' . $database->getSequence(), $collectionId); if ($collection->isEmpty()) { - throw Exception::withParams($this->getNotFoundException(), $collectionId); + throw new Exception($this->getNotFoundException(), params: [$collectionId]); } $response->dynamic($collection, $this->getResponseModel()); diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Indexes/Create.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Indexes/Create.php index 0f1b473bea..b132aff8ef 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Indexes/Create.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Indexes/Create.php @@ -87,14 +87,14 @@ class Create extends Action $db = Authorization::skip(fn () => $dbForProject->getDocument('databases', $databaseId)); if ($db->isEmpty()) { - throw Exception::withParams(Exception::DATABASE_NOT_FOUND, $databaseId); + throw new Exception(Exception::DATABASE_NOT_FOUND, params: [$databaseId]); } $collection = $dbForProject->getDocument('database_' . $db->getSequence(), $collectionId); if ($collection->isEmpty()) { // table or collection. - throw Exception::withParams($this->getGrandParentNotFoundException(), $collectionId); + throw new Exception($this->getGrandParentNotFoundException(), params: [$collectionId]); } $count = $dbForProject->count('indexes', [ @@ -105,7 +105,7 @@ class Create extends Action $limit = $dbForProject->getLimitForIndexes(); if ($count >= $limit) { - throw Exception::withParams($this->getLimitException(), $collectionId); + throw new Exception($this->getLimitException(), params: [$collectionId]); } $oldAttributes = \array_map( @@ -148,7 +148,7 @@ class Create extends Action $attributeIndex = \array_search($attribute, array_column($oldAttributes, 'key')); if ($attributeIndex === false) { - throw Exception::withParams($this->getParentUnknownException(), $attribute); + throw new Exception($this->getParentUnknownException(), params: [$attribute]); } $attributeStatus = $oldAttributes[$attributeIndex]['status']; @@ -160,7 +160,7 @@ class Create extends Action } if ($attributeStatus !== 'available') { - throw Exception::withParams($this->getParentNotAvailableException(), $oldAttributes[$attributeIndex]['key']); + throw new Exception($this->getParentNotAvailableException(), params: [$oldAttributes[$attributeIndex]['key']]); } if (empty($lengths[$i])) { @@ -208,7 +208,7 @@ class Create extends Action try { $index = $dbForProject->createDocument('indexes', $index); } catch (DuplicateException) { - throw Exception::withParams($this->getDuplicateException(), $key); + throw new Exception($this->getDuplicateException(), params: [$key]); } $dbForProject->purgeCachedDocument('database_' . $db->getSequence(), $collectionId); diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Indexes/Delete.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Indexes/Delete.php index b9caeb3720..57198cc53c 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Indexes/Delete.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Indexes/Delete.php @@ -78,19 +78,19 @@ class Delete extends Action $db = Authorization::skip(fn () => $dbForProject->getDocument('databases', $databaseId)); if ($db->isEmpty()) { - throw Exception::withParams(Exception::DATABASE_NOT_FOUND, $databaseId); + throw new Exception(Exception::DATABASE_NOT_FOUND, params: [$databaseId]); } $collection = $dbForProject->getDocument('database_' . $db->getSequence(), $collectionId); if ($collection->isEmpty()) { // table or collection. - throw Exception::withParams($this->getGrandParentNotFoundException(), $collectionId); + throw new Exception($this->getGrandParentNotFoundException(), params: [$collectionId]); } $index = $dbForProject->getDocument('indexes', $db->getSequence() . '_' . $collection->getSequence() . '_' . $key); if (empty($index->getId())) { - throw Exception::withParams($this->getNotFoundException(), $key); + throw new Exception($this->getNotFoundException(), params: [$key]); } // Only update status if removing available index diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Indexes/Get.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Indexes/Get.php index c16ac12a91..c03e80dedc 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Indexes/Get.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Indexes/Get.php @@ -67,18 +67,18 @@ class Get extends Action $database = Authorization::skip(fn () => $dbForProject->getDocument('databases', $databaseId)); if ($database->isEmpty()) { - throw Exception::withParams(Exception::DATABASE_NOT_FOUND, $databaseId); + throw new Exception(Exception::DATABASE_NOT_FOUND, params: [$databaseId]); } $collection = $dbForProject->getDocument('database_' . $database->getSequence(), $collectionId); if ($collection->isEmpty()) { // table or collection. - throw Exception::withParams($this->getGrandParentNotFoundException(), $collectionId); + throw new Exception($this->getGrandParentNotFoundException(), params: [$collectionId]); } $index = $collection->find('key', $key, 'indexes'); if (empty($index)) { - throw Exception::withParams($this->getNotFoundException(), $key); + throw new Exception($this->getNotFoundException(), params: [$key]); } $response->dynamic($index, $this->getResponseModel()); diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Indexes/XList.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Indexes/XList.php index 38213ee4c1..ec4bc94a66 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Indexes/XList.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Indexes/XList.php @@ -75,14 +75,14 @@ class XList extends Action $database = Authorization::skip(fn () => $dbForProject->getDocument('databases', $databaseId)); if ($database->isEmpty()) { - throw Exception::withParams(Exception::DATABASE_NOT_FOUND, $databaseId); + throw new Exception(Exception::DATABASE_NOT_FOUND, params: [$databaseId]); } $collection = $dbForProject->getDocument('database_' . $database->getSequence(), $collectionId); if ($collection->isEmpty()) { // table or collection. - throw Exception::withParams($this->getGrandParentNotFoundException(), $collectionId); + throw new Exception($this->getGrandParentNotFoundException(), params: [$collectionId]); } try { diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Logs/XList.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Logs/XList.php index 7d0b1ab67f..a45daa32a4 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Logs/XList.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Logs/XList.php @@ -79,14 +79,14 @@ class XList extends Action $database = Authorization::skip(fn () => $dbForProject->getDocument('databases', $databaseId)); if ($database->isEmpty()) { - throw Exception::withParams(Exception::DATABASE_NOT_FOUND, $databaseId); + throw new Exception(Exception::DATABASE_NOT_FOUND, params: [$databaseId]); } $collectionDocument = $dbForProject->getDocument('database_' . $database->getSequence(), $collectionId); $collection = $dbForProject->getCollection('database_' . $database->getSequence() . '_collection_' . $collectionDocument->getSequence()); if ($collection->isEmpty()) { - throw Exception::withParams($this->getNotFoundException(), $collectionId); + throw new Exception($this->getNotFoundException(), params: [$collectionId]); } try { diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Update.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Update.php index f1b78bf7c2..bbad2a7f22 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Update.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Update.php @@ -78,12 +78,12 @@ class Update extends Action { $database = Authorization::skip(fn () => $dbForProject->getDocument('databases', $databaseId)); if ($database->isEmpty()) { - throw Exception::withParams(Exception::DATABASE_NOT_FOUND, $databaseId); + throw new Exception(Exception::DATABASE_NOT_FOUND, params: [$databaseId]); } $collection = $dbForProject->getDocument('database_' . $database->getSequence(), $collectionId); if ($collection->isEmpty()) { - throw Exception::withParams($this->getNotFoundException(), $collectionId); + throw new Exception($this->getNotFoundException(), params: [$collectionId]); } $permissions ??= $collection->getPermissions(); diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Usage/Get.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Usage/Get.php index d270bc5efc..c4a46650c9 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Usage/Get.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Usage/Get.php @@ -73,7 +73,7 @@ class Get extends Action $collection = $dbForProject->getCollection('database_' . $database->getSequence() . '_collection_' . $collectionDocument->getSequence()); if ($collection->isEmpty()) { - throw Exception::withParams($this->getNotFoundException(), $collectionId); + throw new Exception($this->getNotFoundException(), params: [$collectionId]); } $periods = Config::getParam('usage', []); diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/XList.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/XList.php index 9430394a19..e1985b0fa9 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/XList.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/XList.php @@ -75,7 +75,7 @@ class XList extends Action $database = Authorization::skip(fn () => $dbForProject->getDocument('databases', $databaseId)); if ($database->isEmpty()) { - throw Exception::withParams(Exception::DATABASE_NOT_FOUND, $databaseId); + throw new Exception(Exception::DATABASE_NOT_FOUND, params: [$databaseId]); } try { diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Create.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Create.php index 7c8d75a2d1..009b499ea8 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Create.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Create.php @@ -84,7 +84,7 @@ class Create extends Action 'type' => $this->getDatabaseType(), ])); } catch (DuplicateException) { - throw Exception::withParams(Exception::DATABASE_ALREADY_EXISTS, $databaseId); + throw new Exception(Exception::DATABASE_ALREADY_EXISTS, params: [$databaseId]); } catch (StructureException $e) { throw new Exception(Exception::DOCUMENT_INVALID_STRUCTURE, $e->getMessage()); } @@ -109,13 +109,13 @@ class Create extends Action try { $dbForProject->createCollection('database_' . $database->getSequence(), $attributes, $indexes); } catch (DuplicateException) { - throw Exception::withParams(Exception::DATABASE_ALREADY_EXISTS, $databaseId); + throw new Exception(Exception::DATABASE_ALREADY_EXISTS, params: [$databaseId]); } catch (IndexException $e) { throw new Exception(Exception::INDEX_INVALID); } catch (LimitException) { // TODO: @Jake, how do we handle this collection/table? // there's no context awareness at this level on what the api is. - throw Exception::withParams(Exception::COLLECTION_LIMIT_EXCEEDED, $databaseId); + throw new Exception(Exception::COLLECTION_LIMIT_EXCEEDED, params: [$databaseId]); } $queueForEvents->setParam('databaseId', $database->getId()); diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Delete.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Delete.php index c181b9ac45..76b36b5df9 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Delete.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Delete.php @@ -69,7 +69,7 @@ class Delete extends Action $database = $dbForProject->getDocument('databases', $databaseId); if ($database->isEmpty()) { - throw Exception::withParams(Exception::DATABASE_NOT_FOUND, $databaseId); + throw new Exception(Exception::DATABASE_NOT_FOUND, params: [$databaseId]); } if (!$dbForProject->deleteDocument('databases', $databaseId)) { diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Get.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Get.php index 33c11efbda..2eb09955c1 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Get.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Get.php @@ -61,7 +61,7 @@ class Get extends Action $database = $dbForProject->getDocument('databases', $databaseId); if ($database->isEmpty()) { - throw Exception::withParams(Exception::DATABASE_NOT_FOUND, $databaseId); + throw new Exception(Exception::DATABASE_NOT_FOUND, params: [$databaseId]); } $response->dynamic($database, UtopiaResponse::MODEL_DATABASE); diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Logs/XList.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Logs/XList.php index 0a496f9b9e..a794ec325e 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Logs/XList.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Logs/XList.php @@ -75,7 +75,7 @@ class XList extends Action $database = $dbForProject->getDocument('databases', $databaseId); if ($database->isEmpty()) { - throw Exception::withParams(Exception::DATABASE_NOT_FOUND, $databaseId); + throw new Exception(Exception::DATABASE_NOT_FOUND, params: [$databaseId]); } try { diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Transactions/Delete.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Transactions/Delete.php index d799ccc200..b018743f36 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Transactions/Delete.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Transactions/Delete.php @@ -60,7 +60,7 @@ class Delete extends Action $transaction = $dbForProject->getDocument('transactions', $transactionId); if ($transaction->isEmpty()) { - throw Exception::withParams(Exception::TRANSACTION_NOT_FOUND, $transactionId); + throw new Exception(Exception::TRANSACTION_NOT_FOUND, params: [$transactionId]); } $dbForProject->deleteDocument('transactions', $transactionId); diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Transactions/Get.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Transactions/Get.php index 3b153fd0a4..78d19ec4eb 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Transactions/Get.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Transactions/Get.php @@ -58,7 +58,7 @@ class Get extends Action $transaction = $dbForProject->getDocument('transactions', $transactionId); if ($transaction->isEmpty()) { - throw Exception::withParams(Exception::TRANSACTION_NOT_FOUND, $transactionId); + throw new Exception(Exception::TRANSACTION_NOT_FOUND, params: [$transactionId]); } $response diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Transactions/Operations/Create.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Transactions/Operations/Create.php index 545031698f..765e663911 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Transactions/Operations/Create.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Transactions/Operations/Create.php @@ -80,7 +80,7 @@ class Create extends Action ? Authorization::skip(fn () => $dbForProject->getDocument('transactions', $transactionId)) : $dbForProject->getDocument('transactions', $transactionId); if ($transaction->isEmpty()) { - throw Exception::withParams(Exception::TRANSACTION_NOT_FOUND, $transactionId); + throw new Exception(Exception::TRANSACTION_NOT_FOUND, params: [$transactionId]); } if ($transaction->getAttribute('status', '') !== 'pending') { throw new Exception(Exception::GENERAL_BAD_REQUEST, 'Invalid or non‑pending transaction'); @@ -115,14 +115,14 @@ class Create extends Action $database = $databases[$operation['databaseId']] ??= Authorization::skip(fn () => $dbForProject->getDocument('databases', $operation['databaseId'])); if ($database->isEmpty() || (!$database->getAttribute('enabled', false) && !$isAPIKey && !$isPrivilegedUser)) { - throw Exception::withParams(Exception::DATABASE_NOT_FOUND, $operation['databaseId']); + throw new Exception(Exception::DATABASE_NOT_FOUND, params: [$operation['databaseId']]); } $collection = $collections[$operation[$this->getGroupId()]] ??= Authorization::skip(fn () => $dbForProject->getDocument('database_' . $database->getSequence(), $operation[$this->getGroupId()])); if ($collection->isEmpty() || (!$collection->getAttribute('enabled', false) && !$isAPIKey && !$isPrivilegedUser)) { - throw Exception::withParams(Exception::COLLECTION_NOT_FOUND, $operation[$this->getGroupId()]); + throw new Exception(Exception::COLLECTION_NOT_FOUND, params: [$operation[$this->getGroupId()]]); } if (\in_array($operation['action'], ['bulkCreate', 'bulkUpdate', 'bulkUpsert', 'bulkDelete'])) { @@ -148,7 +148,7 @@ class Create extends Action $document = $transactionState->getDocument($collectionKey, $documentId, $transactionId); if ($document->isEmpty() && !$isDependant && $operation['action'] !== 'upsert') { - throw Exception::withParams(Exception::DOCUMENT_NOT_FOUND, $documentId); + throw new Exception(Exception::DOCUMENT_NOT_FOUND, params: [$documentId]); } } diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Transactions/Update.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Transactions/Update.php index df9b6f895a..70e670144d 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Transactions/Update.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Transactions/Update.php @@ -118,7 +118,7 @@ class Update extends Action ? Authorization::skip(fn () => $dbForProject->getDocument('transactions', $transactionId)) : $dbForProject->getDocument('transactions', $transactionId); if ($transaction->isEmpty()) { - throw Exception::withParams(Exception::TRANSACTION_NOT_FOUND, $transactionId); + throw new Exception(Exception::TRANSACTION_NOT_FOUND, params: [$transactionId]); } if ($transaction->getAttribute('status', '') !== 'pending') { throw new Exception(Exception::TRANSACTION_NOT_READY); @@ -247,7 +247,7 @@ class Update extends Action 'status' => 'failed', ]))); - throw Exception::withParams(Exception::DOCUMENT_NOT_FOUND, $currentDocumentId ?? 'unknown', previous: $e); + throw new Exception(Exception::DOCUMENT_NOT_FOUND, previous: $e, params: [$currentDocumentId ?? 'unknown']); } catch (DuplicateException | ConflictException $e) { Authorization::skip(fn () => $dbForProject->updateDocument('transactions', $transactionId, new Document([ 'status' => 'failed', diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Update.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Update.php index 4030040ee3..9f2ce06db4 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Update.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Update.php @@ -70,7 +70,7 @@ class Update extends Action $database = $dbForProject->getDocument('databases', $databaseId); if ($database->isEmpty()) { - throw Exception::withParams(Exception::DATABASE_NOT_FOUND, $databaseId); + throw new Exception(Exception::DATABASE_NOT_FOUND, params: [$databaseId]); } $database = $dbForProject->updateDocument('databases', $databaseId, $database diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Usage/Get.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Usage/Get.php index ce0d1ad16d..a717b00ae4 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Usage/Get.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Usage/Get.php @@ -67,7 +67,7 @@ class Get extends Action $database = $dbForProject->getDocument('databases', $databaseId); if ($database->isEmpty()) { - throw Exception::withParams(Exception::DATABASE_NOT_FOUND, $databaseId); + throw new Exception(Exception::DATABASE_NOT_FOUND, params: [$databaseId]); } $periods = Config::getParam('usage', []); diff --git a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Logs/XList.php b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Logs/XList.php index ce1bc35e75..53476dbae1 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Logs/XList.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Logs/XList.php @@ -70,7 +70,7 @@ class XList extends Action $database = $dbForProject->getDocument('databases', $databaseId); if ($database->isEmpty()) { - throw Exception::withParams(Exception::DATABASE_NOT_FOUND, $databaseId); + throw new Exception(Exception::DATABASE_NOT_FOUND, params: [$databaseId]); } try {