Compare commits

...

1 Commits

Author SHA1 Message Date
-LAN-
e4ce2f1e48 refactor(list_operator): replace ValueError with InvalidKeyError
- Improves error handling by using a more specific InvalidKeyError for invalid order keys.
- Enhances code readability and maintainability by distinguishing between error types.
2024-11-03 22:45:22 +08:00

View File

@@ -295,4 +295,4 @@ def _order_file(*, order: Literal["asc", "desc"], order_by: str = "", array: Seq
extract_func = _get_file_extract_number_func(key=order_by)
return sorted(array, key=lambda x: extract_func(x), reverse=order == "desc")
else:
raise ValueError(f"Invalid order key: {order_by}")
raise InvalidKeyError(f"Invalid order key: {order_by}")