-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHTTPExceptions.py
executable file
·81 lines (62 loc) · 1.5 KB
/
HTTPExceptions.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
"""
Helper method to raise exception with 'or':
somethingBoolean() or raise(HTTP400, 'something bad happended')
"""
def raiseEx(exception, message=''):
raise exception(message)
"""Generic HTTPCode exception"""
class HTTPCodeException(Exception): pass
class HTTP400(HTTPCodeException):
"""Bad Request"""
code = 400
class HTTP401(HTTPCodeException):
"""Unauthorized"""
code = 401
class HTTP402(HTTPCodeException):
"""Payment Required"""
code = 402
class HTTP403(HTTPCodeException):
"""Forbidden"""
code = 403
class HTTP404(HTTPCodeException):
"""Not Found"""
code = 404
class HTTP405(HTTPCodeException):
"""Method Not Allowed"""
code = 405
class HTTP406(HTTPCodeException):
"""Not Acceptable"""
code = 406
class HTTP407(HTTPCodeException):
"""Proxy Authentication Required"""
code = 407
class HTTP408(HTTPCodeException):
"""Request Timeout"""
code = 408
class HTTP409(HTTPCodeException):
"""Conflict"""
code = 409
class HTTP410(HTTPCodeException):
"""Gone"""
code = 410
class HTTP411(HTTPCodeException):
"""Length Required"""
code = 411
class HTTP412(HTTPCodeException):
"""Precondition Failed"""
code = 412
class HTTP413(HTTPCodeException):
"""Request Entity Too Large"""
code = 413
class HTTP414(HTTPCodeException):
"""Request-URI Too Long"""
code = 414
class HTTP415(HTTPCodeException):
"""Unsupported Media Type"""
code = 415
class HTTP416(HTTPCodeException):
"""Requested Range Not Satisfiable"""
code = 416
class HTTP417(HTTPCodeException):
"""Expectation Failed"""
code = 417