[Product-Developers] Custom error handling pages

Nathan Van Gheem vangheem at gmail.com
Tue Dec 16 02:59:12 UTC 2008


>
> Ideally I would display through the existing view URL but switch page
> templates so the user can just hit refresh to try again.
>
This is simple.  Might want to look at the BrowserView source and see how it
is called.  Basically, the __call__ method is used to render the page.  So
in there you can do something like,

> def __call__(self):
>
    try:
>
        #do something
>
        return self.template1()
>
    except:
>
        return self.template2()
>
Something like that....

Also note that default_error_message.pt handlers various errors.  You could
throw a custom Exception and handler it your own way in that template.

IMO, a redirect isn't bad either.  You could then create a more concise
error handler.

-Nathan

On Thu, Dec 11, 2008 at 9:49 PM, Nigel Sim <nigel.sim at jcu.edu.au> wrote:

> Hi,
> I am trying to formulate a way of doing custom error handling (as opposed
> to the 'We encountered an error' page), so when I catch an exception I can
> provide a more meaningful response to the user. For instance, within some of
> my BrowserView __init__ or adapters, I call external services which may or
> may not be available. If they are not, currently I throw an exception which
> results in a generic error page.
>
> Ideally I would display through the existing view URL but switch page
> templates so the user can just hit refresh to try again. The other, less
> desirable approach would be to self.request.response.redirect to a common
> error page, and perhaps record the source page so they can click back, like
> the way the login form works.
>
> Does anybody have any throughs on this issue?
>
> Cheers
> nigel
> _______________________________________________
> Product-Developers mailing list
> Product-Developers at lists.plone.org
> http://lists.plone.org/mailman/listinfo/product-developers
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.plone.org/pipermail/plone-product-developers/attachments/20081215/34700919/attachment.html>


More information about the Product-Developers mailing list