Skip to content

Commit

Permalink
implement exceptions
Browse files Browse the repository at this point in the history
Signed-off-by: ItsNeil17 <[email protected]>
  • Loading branch information
ItsNeil17 committed Jun 9, 2024
1 parent 3120d1e commit 707935b
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions backend/exceptions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from __future__ import annotations


class BackendException(BaseException):
"""Base exception for all exceptions in this module"""


class AccessForbidden(BackendException):
def __init__(self, status_code: int) -> None:
super().__init__(f"API returned {status_code}")


class ValidationError(BackendException):
def __init__(self, status_code: int, payload: dict) -> None:
self.payload = payload
super().__init__(
f"API returned {status_code}. This usually occurs to arguments not being specified or the API being unable to process this request. ",
payload,
)

0 comments on commit 707935b

Please sign in to comment.