1
- from .constants import APPLICATION_ERROR , UNAUTHORIZED , NOT_FOUND , BAD_REQUEST
2
- from .constants import METHOD_NOT_ALLOWED , METHOD_NOT_IMPLEMENTED
1
+ from .constants import (APPLICATION_ERROR , UNAUTHORIZED , NOT_FOUND , BAD_REQUEST ,
2
+ FORBIDDEN , NOT_ACCEPTABLE , GONE , PRECONDITION_FAILED ,
3
+ CONFLICT , UNSUPPORTED_MEDIA_TYPE , EXPECTATION_FAILED ,
4
+ I_AM_A_TEAPOT , TOO_MANY_REQUESTS , UNPROCESSABLE_ENTITY ,
5
+ UNAVAILABLE_FOR_LEGAL_REASONS , FAILED_DEPENDENCY ,
6
+ LOCKED )
7
+ from .constants import METHOD_NOT_ALLOWED , METHOD_NOT_IMPLEMENTED , UNAVAILABLE
3
8
4
9
5
10
class RestlessError (Exception ):
@@ -44,6 +49,11 @@ class Unauthorized(HttpError):
44
49
msg = "Unauthorized."
45
50
46
51
52
+ class Forbidden (HttpError ):
53
+ status = FORBIDDEN
54
+ msg = "Permission denied."
55
+
56
+
47
57
class NotFound (HttpError ):
48
58
status = NOT_FOUND
49
59
msg = "Resource not found."
@@ -54,6 +64,72 @@ class MethodNotAllowed(HttpError):
54
64
msg = "The specified HTTP method is not allowed."
55
65
56
66
67
+ class NotAcceptable (HttpError ):
68
+ # TODO: make serializers handle it?
69
+ status = NOT_ACCEPTABLE
70
+ msg = "Unable to send content specified on the request's Accept header(s)."
71
+
72
+
73
+ class Conflict (HttpError ):
74
+ status = CONFLICT
75
+ msg = "There was a conflict when processing the request."
76
+
77
+
78
+ class Gone (HttpError ):
79
+ status = GONE
80
+ msg = "Resource removed permanently."
81
+
82
+
83
+ class PreconditionFailed (HttpError ):
84
+ status = PRECONDITION_FAILED
85
+ msg = "Unable to satisfy one or more request preconditions."
86
+
87
+
88
+ class UnsupportedMediaType (HttpError ):
89
+ status = UNSUPPORTED_MEDIA_TYPE
90
+ msg = "Type of media provided on request is not supported."
91
+
92
+
93
+ class ExpectationFailed (HttpError ):
94
+ status = EXPECTATION_FAILED
95
+ msg = "Unable to satisfy requirements of Expect header."
96
+
97
+
98
+ class IAmATeapot (HttpError ):
99
+ status = I_AM_A_TEAPOT
100
+ msg = "This is a teapot; do not attempt to brew coffee with it."
101
+
102
+
103
+ class UnprocessableEntity (HttpError ):
104
+ status = UNPROCESSABLE_ENTITY
105
+ msg = "Request cannot be followed due to a semantic error."
106
+
107
+
108
+ class Locked (HttpError ):
109
+ status = LOCKED
110
+ msg = "Resource is locked."
111
+
112
+
113
+ class FailedDependency (HttpError ):
114
+ status = FAILED_DEPENDENCY
115
+ msg = "Request failed due to a previous failed request."
116
+
117
+
118
+ class TooManyRequests (HttpError ):
119
+ status = TOO_MANY_REQUESTS
120
+ msg = "There was a conflict when processing the request."
121
+
122
+
123
+ class UnavailableForLegalReasons (HttpError ):
124
+ status = UNAVAILABLE_FOR_LEGAL_REASONS
125
+ msg = "Resource made unavailable by a legal decision."
126
+
127
+
57
128
class MethodNotImplemented (HttpError ):
58
129
status = METHOD_NOT_IMPLEMENTED
59
130
msg = "The specified HTTP method is not implemented."
131
+
132
+
133
+ class Unavailable (HttpError ):
134
+ status = UNAVAILABLE
135
+ msg = "There was a conflict when processing the request."
0 commit comments