diff --git a/src/Database/Adapter/MariaDB.php b/src/Database/Adapter/MariaDB.php index ef4681701..72cec157f 100644 --- a/src/Database/Adapter/MariaDB.php +++ b/src/Database/Adapter/MariaDB.php @@ -11,6 +11,7 @@ use Utopia\Database\Exception as DatabaseException; use Utopia\Database\Exception\Duplicate as DuplicateException; use Utopia\Database\Exception\NotFound as NotFoundException; +use Utopia\Database\Exception\Order as OrderException; use Utopia\Database\Exception\Timeout as TimeoutException; use Utopia\Database\Exception\Truncate as TruncateException; use Utopia\Database\Helpers\ID; @@ -1716,7 +1717,10 @@ public function find(string $collection, array $queries = [], ?int $limit = 25, } if (\is_null($cursor[$originalAttribute] ?? null)) { - throw new DatabaseException("Order attribute '{$originalAttribute}' is empty"); + throw new OrderException( + message: "Order attribute '{$originalAttribute}' is empty", + attribute: $originalAttribute + ); } $binds[':cursor'] = $cursor[$originalAttribute]; diff --git a/src/Database/Adapter/Postgres.php b/src/Database/Adapter/Postgres.php index 2f57b0473..4029f76c8 100644 --- a/src/Database/Adapter/Postgres.php +++ b/src/Database/Adapter/Postgres.php @@ -10,6 +10,7 @@ use Utopia\Database\Document; use Utopia\Database\Exception as DatabaseException; use Utopia\Database\Exception\Duplicate as DuplicateException; +use Utopia\Database\Exception\Order as OrderException; use Utopia\Database\Exception\Timeout as TimeoutException; use Utopia\Database\Exception\Transaction as TransactionException; use Utopia\Database\Exception\Truncate as TruncateException; @@ -1549,7 +1550,10 @@ public function find(string $collection, array $queries = [], ?int $limit = 25, } if (\is_null($cursor[$originalAttribute] ?? null)) { - throw new DatabaseException("Order attribute '{$originalAttribute}' is empty"); + throw new OrderException( + message: "Order attribute '{$originalAttribute}' is empty", + attribute: $originalAttribute + ); } $binds[':cursor'] = $cursor[$originalAttribute]; diff --git a/src/Database/Exception/Order.php b/src/Database/Exception/Order.php new file mode 100644 index 000000000..0ab49094e --- /dev/null +++ b/src/Database/Exception/Order.php @@ -0,0 +1,20 @@ +attribute = $attribute; + parent::__construct($message, $code, $previous); + } + public function getAttribute(): ?string + { + return $this->attribute; + } +}