Closed jbarnoud closed 8 years ago
Silly bug because I didn't clean up properly when migrating to MDAnalysis v0.11.
While the issue with a missing -n
is fixed, missing file for -f
and -s
still give ugly tracebacks.
Good point
Hmm, just came back to this. What is wrong with the current error messages? That a traceback is displayed? What alternative would you suggest?
I'm not sure this can be fixed on the MDreader side. It is a library meant to be used by other scripts; it shouldn't suppress traceback or force the interpreter to quit on its own. It's up to those scripts to handle exceptions.
OTOH, we can have an MDreader creation flag raise_exc=False
. Depending on the value for this flag we would call sys.exit("error msg")
or raise SomeException("error msg")
.
Since MDReader extend argparse, one could expect it to validate the inputs and to catch the missing ones. You would expect a program that use argparse to fail gracefully when an input is missing.
Indeed, it may be useful sometime to be able to catch the exception. Then it would be nice to be also able to distinguish between the exception for a missing traj and the one for a missing topology. The flag, seems a good solution.
If a program that relies on MDreader is called without
-f
,-s
, or-n
, then the program fails duringdo_parse
whith a python traceback.The message for a missing
-f
looks like:The message for a missing
-s
looks like:And the message for a missing
-n
looks like:MDreader could display a more human friendly error message.