Coverage for ghost/exceptions.py: 94%
16 statements
« prev ^ index » next coverage.py v7.5.3, created at 2024-06-17 17:19 +0200
« prev ^ index » next coverage.py v7.5.3, created at 2024-06-17 17:19 +0200
1import pprint
3__all__ = [
4 "BaseGhostException",
5 "GhostResponseException",
6 "GhostUnknownException",
7 "GhostJSONException",
8 "GhostResourceNotFoundException",
9 "GhostWrongApiError",
10]
13class BaseGhostException(Exception):
14 """
15 Base, inherit this cls
16 """
18 def __init__(
19 self, status_code, error_type=None, error_message="", *a, exception=None
20 ):
21 super().__init__(
22 str(status_code), error_type, error_message, *a
23 ) # -> self.args
25 self.status_code = str(status_code)
26 self.error_type = error_type
27 self.error_message = error_message
28 self.exception = exception
30 def __str__(self):
31 return " - ".join(self.args) + "\n" + pprint.pformat(self.exception)
34class GhostResponseException(BaseGhostException):
35 """
36 -> from JSON['errors']
37 """
40class GhostUnknownException(BaseGhostException):
41 """
42 -> if JSON but no errors key
43 """
46class GhostJSONException(BaseGhostException):
47 """
48 -> if JSON could not be parsed
49 """
52class GhostResourceNotFoundException(BaseGhostException):
53 """
54 -> call correct but just no data
55 """
58class GhostWrongApiError(BaseGhostException):
59 """
60 -> content api used instead of admin
61 """