From: Fernando P. <Fer...@co...> - 2004-11-17 17:54:54
|
Jochen Voss schrieb: > Hello Steve, > > On Wed, Nov 17, 2004 at 11:00:32PM +0800, Steve Chaplin wrote: > >>I don't think failure to save a file should be a fatal error. >>Perhaps PS/SVG print_figure() could raise an exception for the GUI >>backend to catch so it can popup an error message and continue. > > Even now you can probably (not tried) catch the SystemExit > exception and prevent the program from aborting. > Do you think raising SystemExit like > > raise SystemExit("error while writing file: permission denied") > > would be good enough. The GUI frontend could catch SystemExit, > check whether the associated value is a string, and then display > this string in an error message box. > > What do you think? Bad design. Doing exception analysis based on string matching for the message is very brittle. A single change in capitalization of the message can break things down the road. It's _far_ better to either: 1. have the ps/svg backends do whatever cleanup they want, and then reraise the original exception unchanged 2. or simply make a matplotlib.SaveError exception which can be explicitly caught based on class matching, which is the preferred python way of doing this. Best, f |