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
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
_logger = logging.getLogger(__name__)


_STATUS_CODE_TO_HTTP_ERRORS: dict[
int, type[web.HTTPError]
] = get_all_aiohttp_http_exceptions(web.HTTPError)
_STATUS_CODE_TO_HTTP_ERRORS: dict[int, type[web.HTTPError]] = (
get_all_aiohttp_http_exceptions(web.HTTPError)
)


class _DefaultDict(dict):
Expand All @@ -40,7 +40,8 @@ def create_error_response(error: ErrorGet, status_code: int) -> web.Response:
return web.json_response(
data={"error": error.model_dump(exclude_unset=True, mode="json")},
dumps=json_dumps,
reason=error.message,
# NOTE: Multiline not allowed in HTTP reason attribute (aiohttp now raises ValueError)
reason=error.message.replace("\n", " ") if error.message else None,
status=status_code,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ class SDSException(HTTPBadRequest): # pylint: disable=too-many-ancestors
"""Basic exception for errors raised inside the module"""

def __init__(self, message: str):
super().__init__(reason=message)
# Multiline not allowed in HTTP reason attribute
super().__init__(reason=message.replace("\n", " ") if message else None)
Loading