Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/Database/Adapter/MariaDB.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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];
Expand Down
6 changes: 5 additions & 1 deletion src/Database/Adapter/Postgres.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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];
Expand Down
20 changes: 20 additions & 0 deletions src/Database/Exception/Order.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace Utopia\Database\Exception;

use Throwable;
use Utopia\Database\Exception;

class Order extends Exception
{
protected ?string $attribute;
public function __construct(string $message, int|string $code = 0, ?Throwable $previous = null, ?string $attribute = null)
{
$this->attribute = $attribute;
parent::__construct($message, $code, $previous);
}
public function getAttribute(): ?string
{
return $this->attribute;
}
}