Lattyware / unrpa

A program to extract files from the RPA archive format.
http://www.lattyware.co.uk/projects/unrpa/
GNU General Public License v3.0
589 stars 74 forks source link

Handle errors gracefully, when extracting files. (Good for partially cor... #3

Closed bashimao closed 6 years ago

bashimao commented 9 years ago

...rupted archives!)

Well, it does what it says. Added 3 lines for error checking to avoid the program from crashing if it faces a difficulty.

Lattyware commented 9 years ago

This seems like bad default behaviour - this should require a flag (continue on error or somesuch), and the exception information should come through standard syntax, not pulling it out of exc_info().

hikari-no-yume commented 9 years ago

Could the exception be somehow annotated?

bashimao commented 9 years ago

The default behavior right now is "silently crash". I am not sure if that is much better. However, since my code will (depending on the actual problem) print rather cryptic error messages, I agree that it might be worthwhile to wrap it into a command line argument. Do you have any wishes regarding what the command line argument should look like? How about:

 --persistent   :     Ignore errors that occur while extracting files
Lattyware commented 9 years ago

I think descriptive is best, even if a little longer - I'd go with --continue-on-error.

The flow I would want to see is catching BaseException, and if the flag hasn't been given, raising a new exception from the caught one with an appropriate message ("An error occurred while trying to extract a file, the cause will be given below. If you wish to try and extract as much from the archive as possible, please use the --continue-on-error flag.").

I'll see about writing it up myself, but I'm a little busy at the moment - if you want to update the pull request, feel free.

Lattyware commented 6 years ago

Added as of latest.