Replace exit(0) on error in library function with an exception #648
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
print
+exit(0)
isn't quite the right tool to indicate a failure to the user here:exit(0)
will result in the whole process completing immediately, even if the user had something else to do (e.g. in an interactive shell or Jupyter notebook they might pause their scripting work and download the dataset, and then come back and rerun the command/cell)0
means it will finish as a success, rather than indicating a failure, which can mean that, for instance, testing passes accidentally because it doesn't notice that the dataset couldn't even be loadedprint
will put output onstdout
, instead ofstderr
, which means some tools won't pick up on itThrowing an exception improves on all of these: