Skip to content

Commit

Permalink
Merge pull request #269 from palewire/patch-4
Browse files Browse the repository at this point in the history
Raise exceptions when `export_chart` fails
  • Loading branch information
chekos authored Apr 6, 2023
2 parents 4f37ce7 + 3b9709b commit db75ab7
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions datawrapper/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ def export_chart(
display : bool, optional
Whether to display the exported image as output in the notebook cell, by default False
Returns
Returns None
-------
IPython.display.Image
If display is True, it returns an Image.
Expand Down Expand Up @@ -537,12 +537,17 @@ def export_chart(
else:
logger.debug(f"File exported at {_filepath}")
elif export_chart_response.status_code == 403:
logger.error("You don't have access to the requested code.")
msg = "You don't have access to the requested chart."
logger.error(msg)
raise Exception(msg)
elif export_chart_response.status_code == 401:
logger.error("You couldn't be authenticated.")
msg = "You couldn't be authenticated."
logger.error(msg)
raise Exception(msg)
else:
logger.error("Couldn't export at this time.")
return None
msg = "Chart could not be exported."
logger.error(msg)
raise Exception(msg)

def get_folders(self) -> Union[Dict[Any, Any], None, Any]:
"""Get a list of folders in your Datawrapper account.
Expand Down

0 comments on commit db75ab7

Please sign in to comment.