-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Do you know if this actually impacts things when used e.g. via the command line? Like if we use check-datapackage internally in Flower, does check-datapackage's exception changes also change exceptions in Flower?
Currently yes, and that's why I did this more elaborate rewrite so so that they would play nicely with each other. But it doesn't have to work this way. There are alternatives to modifying
sys.excepthook, such as using individualtry/exceptstatements where we expect our custom errors to be raised. The downside would be that it is less automatic/implicit and we would need try/except logic at every place where our custom error might occur (which aren't that many, maybe even just one forcheck-datapackage). One could argue that this would be cleaner and I see it more commonly elsewhere, but since we already had modifiedsys.excepthookearlier incheck-datapackageI continued on that approach here. Maybe that was not the best choice though now that I reflect on it... It does get messy to modify a global state like this. I'm down to switch it around and use try/except instead (we already use it in flower to customize the error message so it wouldn't be that much additional logic there either I think).I can explore that in a separate PR. We would still need to move the exception pretty printing to
soil, but maybe we could actually get rid of most of the complicated traceback chaining. I'm not 100% it will work the same way for IPython, but it seems like it could become much cleaner if it does work well.One thing of note though, modifying
sys.excepthookis the only way to suppress tracebacks of all error messages. So if we change to try/except, the user would still get a giant error message if a regular python exception is raised (rather than one of our custom ones). This could be seen as a good thing as it is easier to troubleshoot unknown errors that we haven't accounted for, but maybe the reason for using sys.excepthook in the first place was a desire to control the tracebacks from all errors? How do you want the program to behave here, is it ok if we remove the traceback only for our custom errors that we are expecting to raise, or do you want it to be removed for all possible errors even those we don't raise explicitly ourselves?
Originally posted by @joelostblom in #309
Metadata
Metadata
Assignees
Labels
Type
Projects
Status