-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexceptions.py
43 lines (31 loc) · 1.38 KB
/
exceptions.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
from rest_framework import status
class InvalidRequestError(Exception):
def __init__(self, msg="invalid reuest params", *args, **kwargs) -> None:
self.status = status.HTTP_400_BAD_REQUEST
super().__init__(msg, *args, **kwargs)
class AudioFileNotReadyError(Exception):
def __init__(
self, msg="audio file is not ready. please try agian later.", *args, **kwargs
) -> None:
self.status = status.HTTP_202_ACCEPTED
super().__init__(msg, *args, **kwargs)
class NotFoundUserError(Exception):
def __init__(
self, msg="User Not Found. Please Check ID or Password", *args, **kwargs
) -> None:
self.status = status.HTTP_400_BAD_REQUEST
super().__init__(msg, *args, **kwargs)
class NotAuthorizedError(Exception):
def __init__(self, msg="Login Required", *args, **kwargs):
self.status = status.HTTP_403_FORBIDDEN
super().__init__(msg, *args, **kwargs)
class NoPermssionError(Exception):
def __init__(
self, msg="Not allowed request. Please check your permission", *args, **kwargs
):
self.status = status.HTTP_403_FORBIDDEN
super().__init__(msg, *args, **kwargs)
class TokenExpiredError(Exception):
def __init__(self, msg="Login time expired. Please login again", *args, **kwargs):
self.status = status.HTTP_403_FORBIDDEN
super().__init__(msg, *args, **kwargs)