|
From: John H. <jdh...@ac...> - 2004-11-23 21:29:03
|
>>>>> "Steve" == Steve Chaplin <ste...@ya...> writes:
Steve> I've updated backend_gtk.py in cvs to use a default
Steve> exception handler, and noticed a few things in the process:
Steve> - sys.excepthook does not catch SystemExit, which is what
Steve> we wanted anyway.
I think the full exception should be printed. It makes debugging very
hard, otherwise. In fact, while recently debugging some code, I
commented out the exception handler for this reason. matplotlib.cbook
provides a method exception_to_str to convert a traceback to a string.
Steve> - for some errors I needed to display a matplotlib message
Steve> rather than the default exception message, or to raise an
Steve> exception where error_msg () was used with no exception. I
Steve> added an 'MPLError' exception, its probably best to move it
Steve> into a central file if other people need to use it also.
Perhaps in matplotlib.__init__ ?
Steve> - changing from error_msg() to raise exception means the
Steve> rest of the method will not execute, which I hadn't thought
Steve> about. This is no good for 'get_filename_from_user()' where
Steve> I want to loop until a file (or Cancel) is selected. So I
Steve> think GTK still has a need to use of a popup message dialog
Steve> occasionally. And for print_figure() it means the section
Steve> of code to restore figure settings will not get executed
Steve> after an error.
I agree that a general facility to popup a message is useful How
abouts we follow Jochen's suggestion and make is a FigureManager
method?
As for your get_filename / restore figure problems, can't these be
addressed by try/catching the exceptions locally, and restoring the
figure state before forwarding the exception onwards?
JDH
|