Skip to content

Commit

Permalink
separate decode error handling from unexpected error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
ekneg54 committed Aug 27, 2024
1 parent 7ea230d commit aa66542
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion logprep/connector/http/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
from falcon import ( # pylint: disable=no-name-in-module
HTTP_200,
HTTPBadRequest,
HTTPInternalServerError,
HTTPMethodNotAllowed,
HTTPTooManyRequests,
HTTPUnauthorized,
Expand Down Expand Up @@ -145,8 +146,14 @@ async def func_wrapper(*args, **kwargs):
raise error from error
except queue.Full as error:
raise HTTPTooManyRequests(description="Logprep Message Queue is full.") from error
except msgspec.DecodeError as error:
raise HTTPBadRequest(
description=f"Can't decode message due to: {str(error)}"
) from error
except Exception as error: # pylint: disable=broad-except
raise HTTPBadRequest(str(error)) from error
raise HTTPInternalServerError(
description=f"Unexpected Exception: {str(error)}"
) from error
return func_wrapper

return func_wrapper
Expand Down

0 comments on commit aa66542

Please sign in to comment.