From 144e723431457f28026f34d0bcb1f8e9e51dacc0 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Wed, 21 Sep 2022 18:36:43 +1200 Subject: [PATCH] Update error handling --- app/config/errors.php | 4 ++-- app/controllers/api/graphql.php | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/config/errors.php b/app/config/errors.php index fe32a4cab1..7e6dc64b21 100644 --- a/app/config/errors.php +++ b/app/config/errors.php @@ -551,7 +551,7 @@ return [ ], Exception::GRAPHQL_NO_QUERY => [ 'name' => Exception::GRAPHQL_NO_QUERY, - 'description' => 'Query is required.', + 'description' => 'No query supplied.', 'code' => 400, ], Exception::GRAPHQL_INVALID_QUERY => [ @@ -561,7 +561,7 @@ return [ ], Exception::GRAPHQL_TOO_MANY_QUERIES => [ 'name' => Exception::GRAPHQL_TOO_MANY_QUERIES, - 'description' => 'Too many queries have been sent in the same request.', + 'description' => 'Too many queries.', 'code' => 400, ], ]; diff --git a/app/controllers/api/graphql.php b/app/controllers/api/graphql.php index 6a41890544..97d07283ca 100644 --- a/app/controllers/api/graphql.php +++ b/app/controllers/api/graphql.php @@ -118,14 +118,14 @@ function executeRequest( $query = [$query]; } if (empty($query)) { - throw new Exception('No query supplied.', 400, Exception::GRAPHQL_NO_QUERY); + throw new Exception(Exception::GRAPHQL_NO_QUERY); } if (\count($query) > $maxBatchSize) { - throw new Exception('Too many queries.', 400, Exception::GRAPHQL_TOO_MANY_QUERIES); + throw new Exception(Exception::GRAPHQL_TOO_MANY_QUERIES); } foreach ($query as $item) { if (empty($item['query'])) { - throw new Exception('Invalid query.', 400, Exception::GRAPHQL_INVALID_QUERY); + throw new Exception(Exception::GRAPHQL_INVALID_QUERY); } }