Skip to content

Commit 85134b0

Browse files
committed
Show detailed error if available
1 parent 27e094b commit 85134b0

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

quickchart/__init__.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -91,16 +91,20 @@ def _post(self, url):
9191
postdata['key'] = self.key
9292
resp = requests.post(url, json=postdata)
9393
if resp.status_code != 200:
94+
err_description = resp.headers.get('x-quickchart-error')
9495
raise RuntimeError(
95-
'Invalid response code from chart creation endpoint')
96+
'Invalid response code from chart creation endpoint: %d%s'
97+
% (resp.status_code, '\n%s' % err_description if err_description else '')
98+
)
9699
return resp
97100

101+
98102
def get_short_url(self):
99103
resp = self._post('%s/chart/create' % self.get_url_base())
100104
parsed = json.loads(resp.text)
101105
if not parsed['success']:
102106
raise RuntimeError(
103-
'Failure response status from chart creation endpoint')
107+
'Chart creation endpoint failed to create chart')
104108
return parsed['url']
105109

106110
def get_bytes(self):

0 commit comments

Comments
 (0)