diff --git a/plotly/plotly/plotly.py b/plotly/plotly/plotly.py index 250764295f3..c754cfb5467 100644 --- a/plotly/plotly/plotly.py +++ b/plotly/plotly/plotly.py @@ -1586,15 +1586,24 @@ 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 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] +