From: Chuck E. <ChuckEsterbrook@StockAlerts.com> - 2002-02-13 07:51:21
|
On Tuesday 12 February 2002 01:39 pm, Clark C . Evans wrote: > Hello. I was wondering what incantation I need so that > my servlet's "sleep()" function is called whenever a > error is thrown? > > Thanks! In pre-CVS WebKit you could do something like: def writeHTML(self): try: Page.writeHTML(self) finally: if not self.slept: self.sleep(self.transaction()) (I haven't tested this.) Obviously, your awake() will set slept to 0 and sleep() will set it to 1 and also do a no-op if it is already 1. The try:finally: is probably overkill as sleep() should not be invoked when writeHTML() is finished. However, with the changes I just checked in 10 minutes ago, you could do this: class SitePage: def writeExceptionReport(self, handler): handler.writeTitle(self.__class__.__name__) try: self.sleep(self.transaction()) except: handler.writeln('Uncaught exception when invoking sleep():<br><pre>') traceback.print_exc(file=handler) handler.writeln('</pre>') Again, untested. That felt good. It's been awhile since I answered a question. :-) -Chuck |