1
0
Fork 0
mirror of synced 2024-06-02 19:04:49 +12:00

feat: move query errors to general category

This commit is contained in:
Christy Jacob 2022-02-09 01:34:26 +04:00
parent d410dc5f3d
commit d5dd6a17b8
3 changed files with 14 additions and 19 deletions

View file

@ -48,6 +48,16 @@ return [
'description' => 'The request contains one or more invalid arguments. Please refer to the endpoint documentation.',
'code' => 400,
],
Exception::GENERAL_QUERY_LIMIT_EXCEEDED => [
'name' => Exception::GENERAL_QUERY_LIMIT_EXCEEDED,
'description' => 'Query limit exceeded for the current attribute. Usage of more than 100 query values on a single attribute is prohibited.',
'code' => 400,
],
Exception::GENERAL_QUERY_INVALID => [
'name' => Exception::GENERAL_QUERY_INVALID,
'description' => 'The query\'s syntax is invalid. Please check the query and try again.',
'code' => 400,
],
Exception::GENERAL_SERVER_ERROR => [
'name' => Exception::GENERAL_SERVER_ERROR,
'description' => 'An internal server error occurred.',
@ -359,18 +369,6 @@ return [
'code' => 409,
],
/** Query */
Exception::QUERY_LIMIT_EXCEEDED => [
'name' => Exception::QUERY_LIMIT_EXCEEDED,
'description' => 'Query limit exceeded for the current attribute. Usage of more than 100 query values on a single attribute is prohibited.',
'code' => 400,
],
Exception::QUERY_INVALID => [
'name' => Exception::QUERY_INVALID,
'description' => 'Your query syntax is invalid. Please check your query and try again.',
'code' => 400,
],
/** Project Errors */
Exception::PROJECT_NOT_FOUND => [
'name' => Exception::PROJECT_NOT_FOUND,

View file

@ -1726,7 +1726,7 @@ App::get('/v1/database/collections/:collectionId/documents')
$query = Query::parse($query);
if (\count($query->getValues()) > 100) {
throw new Exception("You cannot use more than 100 query values on attribute '{$query->getAttribute()}'", 400, Exception::QUERY_LIMIT_EXCEEDED);
throw new Exception("You cannot use more than 100 query values on attribute '{$query->getAttribute()}'", 400, Exception::GENERAL_QUERY_LIMIT_EXCEEDED);
}
return $query;
@ -1735,7 +1735,7 @@ App::get('/v1/database/collections/:collectionId/documents')
if (!empty($queries)) {
$validator = new QueriesValidator(new QueryValidator($collection->getAttribute('attributes', [])), $collection->getAttribute('indexes', []), true);
if (!$validator->isValid($queries)) {
throw new Exception($validator->getDescription(), 400, Exception::QUERY_INVALID);
throw new Exception($validator->getDescription(), 400, Exception::GENERAL_QUERY_INVALID);
}
}

View file

@ -24,7 +24,6 @@ class Exception extends \Exception
* - Documents
* - Attributes
* - Indexes
* - Queries
* - Projects
* - Webhooks
* - Keys
@ -41,6 +40,8 @@ class Exception extends \Exception
const GENERAL_RATE_LIMIT_EXCEEDED = 'general_rate_limit_exceeded';
const GENERAL_SMTP_DISABLED = 'general_smtp_disabled';
const GENERAL_ARGUMENT_INVALID = 'general_argument_invalid';
const GENERAL_QUERY_LIMIT_EXCEEDED = 'general_query_limit_exceeded';
const GENERAL_QUERY_INVALID = 'general_query_invalid';
const GENERAL_SERVER_ERROR = 'general_server_error';
/** Users */
@ -123,10 +124,6 @@ class Exception extends \Exception
const INDEX_LIMIT_EXCEEDED = 'index_limit_exceeded';
const INDEX_ALREADY_EXISTS = 'index_already_exists';
/** Query */
const QUERY_LIMIT_EXCEEDED = 'query_limit_exceeded';
const QUERY_INVALID = 'query_invalid';
/** Projects */
const PROJECT_NOT_FOUND = 'project_not_found';
const PROJECT_UNKNOWN = 'project_unknown';