Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raise exceptions when export_chart fails #269

Merged
merged 1 commit into from
Apr 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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