srnas / barnaba

Analyse Nucleic Acids Structure and Simulations with baRNAba
GNU General Public License v3.0
38 stars 15 forks source link

Raise exceptions instead of sys.exit #62

Open ollyfutur opened 6 months ago

ollyfutur commented 6 months ago

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 catching SystemExit in a try block, I suggest Barnaba should raise a ValueError to align with python error handling conventions.

Changes