you can do something like this for the whole app:
def yeld_errors(handler):
try:
return handler()
except Exception, e:
yield str(e)
app.add_processor(yeld_errors)
On Dec 15, 11:41 am, je <[email protected]> wrote:
> I'm using version 0.33.
>
> try...except is what I am using right now, but with 20 or more classes
> in this application, that's a lot of repetitive code to handle
> unexpected errors.
>
> Is there a way to "try...except" the whole app for unexpected errors,
> like I would do in a regular python script with:
>
> try:
> main()
> except:
> display/log the error
>
> ?
>
> On 14 déc, 23:23, "W. Martin Borgert" <[email protected]> wrote:
>
> > Quoting je <[email protected]>:
>
> > > So, how, if possible, could I get the error displayed inside a
> > > generator function using yield?
>
> > Maybe sth. like this (if you want to have the error message shown
> > in your web page):
>
> > def GET(self):
> > try:
> > err1()
> > yield ...
> > err2()
> > except Exception, e:
> > yield str(e) # or similar
>
> > Or if you want it printed on the console:
>
> > except Exception, e:
> > print str(e) # or add the stack trace from Python
>
> > Just to be sure: You are using a recent web.py (> 0.3x) which
> > does not use "print" anymore to return the HTML, right?
>
>
--
You received this message because you are subscribed to the Google Groups
"web.py" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/webpy?hl=en.