File tree 1 file changed +11
-1
lines changed
1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change 4
4
from __future__ import print_function
5
5
from __future__ import unicode_literals
6
6
7
+ from requests .compat import json
8
+
7
9
8
10
class CoinbaseError (Exception ):
9
11
"""Base error class for all exceptions raised in this library.
@@ -83,6 +85,10 @@ class InternalServerError(APIError):
83
85
pass
84
86
85
87
88
+ class BadGatewayError (APIError ):
89
+ pass
90
+
91
+
86
92
class ServiceUnavailableError (APIError ):
87
93
pass
88
94
@@ -91,7 +97,10 @@ def build_api_error(response, blob=None):
91
97
"""Helper method for creating errors and attaching HTTP response/request
92
98
details to them.
93
99
"""
94
- blob = blob or response .json ()
100
+ try :
101
+ blob = blob or response .json ()
102
+ except json .JSONDecodeError :
103
+ blob = {}
95
104
error_list = blob .get ('errors' , None )
96
105
error = (error_list [0 ] if error_list else {})
97
106
if error :
@@ -135,5 +144,6 @@ def build_api_error(response, blob=None):
135
144
422 : ValidationError ,
136
145
429 : RateLimitExceededError ,
137
146
500 : InternalServerError ,
147
+ 502 : BadGatewayError ,
138
148
503 : ServiceUnavailableError ,
139
149
}
You can’t perform that action at this time.
0 commit comments