Skip to content

Commit 71776c3

Browse files
author
Deniz Alpaslan
committed
update utils.py and collection.py to raise SortValidationError
1 parent df2ab2f commit 71776c3

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

arango/collection.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -773,6 +773,7 @@ def find(
773773
:return: Document cursor.
774774
:rtype: arango.cursor.Cursor
775775
:raise arango.exceptions.DocumentGetError: If retrieval fails.
776+
:raise arango.exceptions.SortValidationError: If sort parameters are invalid.
776777
"""
777778
assert isinstance(filters, dict), "filters must be a dict"
778779
assert is_none_or_int(skip), "skip must be a non-negative int"

arango/utils.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from contextlib import contextmanager
1212
from typing import Any, Iterator, Sequence, Union
1313

14-
from arango.exceptions import DocumentParseError
14+
from arango.exceptions import DocumentParseError, SortValidationError
1515
from arango.typings import Json, Jsons
1616

1717

@@ -135,16 +135,16 @@ def validate_sort_parameters(sort: Sequence[Json]) -> bool:
135135
:type sort: Sequence[Json]
136136
:return: Validation success.
137137
:rtype: bool
138-
:raise arango.exceptions.DocumentGetError: If sort parameters are invalid.
138+
:raise arango.exceptions.SortValidationError: If sort parameters are invalid.
139139
"""
140140
assert isinstance(sort, Sequence)
141141
for param in sort:
142142
if "sort_by" not in param or "sort_order" not in param:
143-
raise DocumentParseError(
143+
raise SortValidationError(
144144
"Each sort parameter must have 'sort_by' and 'sort_order'."
145145
)
146146
if param["sort_order"].upper() not in ["ASC", "DESC"]:
147-
raise DocumentParseError("'sort_order' must be either 'ASC' or 'DESC'")
147+
raise SortValidationError("'sort_order' must be either 'ASC' or 'DESC'")
148148
return True
149149

150150

0 commit comments

Comments
 (0)