Skip to content

Commit

Permalink
Handle exceptions in a proper way
Browse files Browse the repository at this point in the history
  • Loading branch information
folix-01 committed Sep 26, 2023
1 parent b2259fe commit 8ded7dc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/redturtle/prenotazioni/exceptions/booker.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ class BookerException(Exception):


class BookingsLimitExceded(BookerException):
def __init__(self, *args, **kwargs):
if "message" not in kwargs.keys():
kwargs["message"] = "Booking limit is exceed for the current user"
def __init__(
self, message="Booking limit is exceed for the current user", *args, **kwargs
):
return super().__init__(message, *args, **kwargs)
2 changes: 1 addition & 1 deletion src/redturtle/prenotazioni/restapi/services/booking/add.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def reply(self):
else:
obj = booker.book(data=book_data)
except BookerException as e:
raise BadRequest(e.args[0])
raise BadRequest(str(e))
if not obj:
msg = self.context.translate(
_("Sorry, this slot is not available anymore.")
Expand Down

0 comments on commit 8ded7dc

Please sign in to comment.