Raise exceptions instead of sys.exit #62
Open
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.
Motivation
I got stuck for a little while on a problem with Barnaba while processing a dataset using multiprocessing. Some files caused the program to exit because no valid nucleobase was found. I did not expect this behavior which caused my program to inexplicably stall since sub-processes exited without raising an Exception that I could identify. In my case the problematic piece of code was in the
Nucleic
constructor. While this is quickly fixable in the caller by explicitly catchingSystemExit
in atry
block, I suggest Barnaba should raise aValueError
to align with python error handling conventions.Changes
sys.stderr.write
+sys.exit
is found in many places in the code. I have replaced these occurrences withValueError
s in the parts that can be used as modules (aka everywhere except in commandline.py)