I put this in my model file and it did exactly what I wanted. Thanks!
Is there a reason my attempts to use sys.excepthook failed? This was
my test code, which triggered the normal web2py exception handling,
which pointed to the "raise" line:
--
import sys
def handler(t, v, tb):
redirect("http://example.com")
sys.excepthook = handler
raise Exception("should trigger a redirect")
---
On Jan 14, 12:28 pm, Massimo Di Pierro <[email protected]>
wrote:
> you can do, in controller
>
> def mycaller(f):
> try:
> return f()
> except IOError:
> redirect(URL('my_IOError_page'))
>
> response._caller = mycaller
>
> response._caller wraps all action calls. Give it a try and let us know
> if this works.
>
> On Jan 13, 8:23 pm, spiffytech <[email protected]> wrote:
>
>
>
>
>
>
>
> > My web2py application is littered with calls to a library that loves
> > throwing exceptions when the website it connects to isn't available.
> > I'd like my web2py app to catch the exceptions thrown by the library
> > and redirect the user to a friendly error page. However, there are too
> > many library calls to load up the app with try/except statements all
> > over the place.
>
> > Is there something I can put in my models file that will catch all
> > exceptions of a certain type and handle them?