From: Jochen V. <vo...@se...> - 2004-11-18 16:22:06
|
Hello Steve, On Thu, Nov 18, 2004 at 11:38:10PM +0800, Steve Chaplin wrote: > At the moment the PS backend does > try: > fh =3D file(outfile, 'w') > except IOError: > error_msg_ps('Could not open %s for writing' % outfile) >=20 > which translates into > try: > fh =3D file(outfile, 'w') > except IOError: > verbose.report_error('Error: Could not open %s for writing' % > outfile) > sys.exit() >=20 > The backend does not do any cleanup after the exception, so I think it > could be changed to just > fh =3D file(outfile, 'w') As I understood John, the plan is to report error messages via the verbose.report_error function. Where would this be called with the modified code (especially when there is no GUI backend active)? > allowing the exception terminate the program with the error message > appearing at the end of the traceback. This looks really ugly to me. But maybe it is the script author's responsibility to catch this if he cares about this. > Then the GUI backends can then do > from backend_svg import FigureCanvasSVG as FigureCanvas > try: > fc =3D self.switch_backends(FigureCanvas) > fc.print_figure(filename, dpi, facecolor, edgecolor, > orientation) > except IOError, exc: > error_msg("%s: %s" % (exc.filename, exc.strerror), parent=3Dself) What about other exceptions thrown by the backend? I see that passing the original exception to the caller is cleaner and I would be happy to change the PostScript backend to do this. The only question for me is: how and when is the "report_error" function to be used? All the best, Jochen --=20 http://seehuhn.de/ |