Hi Pat,

Sending a redirect in case of error is generally a bad idea, for several
reasons:
- It disguises the error as a redirect for clients (Eg, 302 instead of 500)
- By redirecting the user to the error page, they can no longer simply hit
refresh to try again for transient errors, nor can they copy the URL that's
problematic.

Instead, the usual approach is something like this:

- Define a common base class that subclasses webapp.RequestHandler.
- Override the error(code) method to generate and return an error page.
- Make all your app's handlers inherit from your base handler.
- Call self.error(code) and return whenever you need to.

-Nick

On Mon, Sep 14, 2009 at 8:28 PM, PatHaugen <[email protected]> wrote:

>
> Currently the simplest way I've handled errors is by making a page
> like others:
>
> class ErrorPage(webapp.RequestHandler):
> ...
> application = webapp.WSGIApplication(
> ...
> ('/errorpage', ErrorPage),
>
> Then, I use:
> self.redirect('/errorpage')
>
> In any and all if/else branches where there should be an error and I
> want to stop running the remaining code.
>
> However, I was wondering if there was a better way than just using the
> 'self.redirect' to handle errors and perform stops on running code?
> >
>


-- 
Nick Johnson, Developer Programs Engineer, App Engine

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google App Engine" 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/google-appengine?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to