2022-09-17 18:12:14 +00:00
|
|
|
from graphql.error import GraphQLError
|
2021-06-28 09:08:09 +00:00
|
|
|
|
2022-11-02 09:23:14 +00:00
|
|
|
|
2023-10-26 21:07:35 +00:00
|
|
|
# TODO: remove traceback from logs for defined exceptions
|
2023-10-26 17:56:42 +00:00
|
|
|
|
2021-06-28 09:08:09 +00:00
|
|
|
class BaseHttpException(GraphQLError):
|
|
|
|
code = 500
|
|
|
|
message = "500 Server error"
|
|
|
|
|
|
|
|
|
2022-10-31 21:05:10 +00:00
|
|
|
class ExpiredToken(BaseHttpException):
|
2022-11-01 22:38:49 +00:00
|
|
|
code = 401
|
|
|
|
message = "401 Expired Token"
|
2022-10-31 21:05:10 +00:00
|
|
|
|
|
|
|
|
2021-06-28 09:08:09 +00:00
|
|
|
class InvalidToken(BaseHttpException):
|
2022-11-01 22:38:49 +00:00
|
|
|
code = 401
|
|
|
|
message = "401 Invalid Token"
|
2021-06-28 09:08:09 +00:00
|
|
|
|
|
|
|
|
2022-10-31 21:17:00 +00:00
|
|
|
class Unauthorized(BaseHttpException):
|
|
|
|
code = 401
|
|
|
|
message = "401 Unauthorized"
|
|
|
|
|
|
|
|
|
2021-06-28 09:08:09 +00:00
|
|
|
class ObjectNotExist(BaseHttpException):
|
|
|
|
code = 404
|
|
|
|
message = "404 Object Does Not Exist"
|
|
|
|
|
|
|
|
|
|
|
|
class OperationNotAllowed(BaseHttpException):
|
|
|
|
code = 403
|
2022-10-31 21:17:00 +00:00
|
|
|
message = "403 Operation Is Not Allowed"
|
2021-06-28 09:08:09 +00:00
|
|
|
|
|
|
|
|
|
|
|
class InvalidPassword(BaseHttpException):
|
2022-10-31 21:17:00 +00:00
|
|
|
code = 403
|
|
|
|
message = "403 Invalid Password"
|