FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
python-http-client/python_http_client/exceptions.py at master · CCProdigy/python-http-client · GitHub
CCProdigy
/
python-http-client
Public
forked from
sendgrid/python-http-client
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
python-http-client
/
python_http_client
/
exceptions.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
85 lines (55 loc) · 1.41 KB
Breadcrumbs
python-http-client
/
python_http_client
/
exceptions.py
Copy path
File metadata and controls
85 lines (55 loc) · 1.41 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
82
83
84
85
import
json
class
HTTPError
(
Exception
):
""" Base of all other errors"""
def
__init__
(
self
,
error
):
self
.
status_code
=
error
.
code
self
.
reason
=
error
.
reason
self
.
body
=
error
.
read
()
self
.
headers
=
error
.
hdrs
@
property
def
to_dict
(
self
):
"""
:return: dict of response error from the API
"""
return
json
.
loads
(
self
.
body
.
decode
(
'utf-8'
))
class
BadRequestsError
(
HTTPError
):
pass
class
UnauthorizedError
(
HTTPError
):
pass
class
ForbiddenError
(
HTTPError
):
pass
class
NotFoundError
(
HTTPError
):
pass
class
MethodNotAllowedError
(
HTTPError
):
pass
class
PayloadTooLargeError
(
HTTPError
):
pass
class
UnsupportedMediaTypeError
(
HTTPError
):
pass
class
TooManyRequestsError
(
HTTPError
):
pass
class
InternalServerError
(
HTTPError
):
pass
class
ServiceUnavailableError
(
HTTPError
):
pass
class
GatewayTimeoutError
(
HTTPError
):
pass
err_dict
=
{
400
:
BadRequestsError
,
401
:
UnauthorizedError
,
403
:
ForbiddenError
,
404
:
NotFoundError
,
405
:
MethodNotAllowedError
,
413
:
PayloadTooLargeError
,
415
:
UnsupportedMediaTypeError
,
429
:
TooManyRequestsError
,
500
:
InternalServerError
,
503
:
ServiceUnavailableError
,
504
:
GatewayTimeoutError
}
def
handle_error
(
error
):
try
:
exc
=
err_dict
[
error
.
code
](
error
)
except
KeyError
:
return
HTTPError
(
error
)
return
exc
Back
|
FazBrowse Home
|
New Git URL