From 4b53e787aca350928d16bf4cc7acbbb23b30bcbf Mon Sep 17 00:00:00 2001 From: Adam Kulidjian Date: Tue, 6 Dec 2016 17:59:37 -0500 Subject: [PATCH 1/2] supported 5/9 of chris' suggested error msgs --- plotly/plotly/plotly.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plotly/plotly/plotly.py b/plotly/plotly/plotly.py index 250764295f3..475a521a8b2 100644 --- a/plotly/plotly/plotly.py +++ b/plotly/plotly/plotly.py @@ -1586,15 +1586,15 @@ def create_animations(figure, filename=None, sharing='public', auto_open=True): api_url = _api_v2.api_url('plots') r = requests.post(api_url, auth=auth, headers=headers, json=json) - r.raise_for_status() try: parsed_response = r.json() except: parsed_response = r.content - if 'error' in r and r['error'] != '': - raise exceptions.PlotlyError(r['error']) + # raise error message + if r.ok is False: + raise exceptions.PlotlyError(parsed_response['errors'][-1]['message']) if sharing == 'secret': web_url = (parsed_response['file']['web_url'][:-1] + From 39938291d6359de60f222b9369cbe2255f109381 Mon Sep 17 00:00:00 2001 From: Adam Kulidjian Date: Wed, 7 Dec 2016 13:51:06 -0500 Subject: [PATCH 2/2] andrew's comments --- plotly/plotly/plotly.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/plotly/plotly/plotly.py b/plotly/plotly/plotly.py index 475a521a8b2..c754cfb5467 100644 --- a/plotly/plotly/plotly.py +++ b/plotly/plotly/plotly.py @@ -1593,8 +1593,17 @@ def create_animations(figure, filename=None, sharing='public', auto_open=True): parsed_response = r.content # raise error message - if r.ok is False: - raise exceptions.PlotlyError(parsed_response['errors'][-1]['message']) + if not r.ok: + message = '' + if isinstance(parsed_response, dict): + errors = parsed_response.get('errors') + if errors and errors[-1].get('message'): + message = errors[-1]['message'] + if message: + raise exceptions.PlotlyError(message) + else: + # shucks, we're stuck with a generic error... + r.raise_for_status() if sharing == 'secret': web_url = (parsed_response['file']['web_url'][:-1] +