File tree Expand file tree Collapse file tree 1 file changed +25
-1
lines changed
Expand file tree Collapse file tree 1 file changed +25
-1
lines changed Original file line number Diff line number Diff line change 1515
1616
1717"""
18-
18+ import json
1919
2020## Base Plotly Error ##
2121
@@ -27,6 +27,30 @@ class InputError(Exception):
2727 pass
2828
2929
30+ class PlotlyRequestError (Exception ):
31+ def __init__ (self , requests_exception ):
32+ self .status_code = requests_exception .response .status_code
33+ self .HTTPError = requests_exception
34+ content_type = requests_exception .response .headers ['content-type' ]
35+ if 'json' in content_type :
36+ content = requests_exception .response .content
37+ if content != '' :
38+ res_payload = json .loads (requests_exception .response .content )
39+ if 'detail' in res_payload :
40+ self .message = res_payload ['detail' ]
41+ else :
42+ self .message = ''
43+ else :
44+ self .message = ''
45+ elif content_type == 'text/plain' :
46+ self .message = requests_exception .response .content
47+ else :
48+ self .message = requests_exception .message
49+
50+ def __str__ (self ):
51+ return self .message
52+
53+
3054## Grid Errors ##
3155
3256COLUMN_NOT_YET_UPLOADED_MESSAGE = (
You can’t perform that action at this time.
0 commit comments