Making A 404 Error Page

43 views
Skip to first unread message

Larry....@googlemail.com

unread,
Sep 3, 2008, 1:40:14 PM9/3/08
to Google App Engine
Hi!

As the title suggests, I am very new to Google App Engine. Really my
question is as simple as the title: How can I make it so that instead
of an error on a white page being shown, the browser is shown a custom
404 page? Searching yields some stuff related to Django but I'm just
using standard App Engine and templates.

Thanks,
Larry

googleapps

unread,
Sep 3, 2008, 1:43:29 PM9/3/08
to Google App Engine
Do a catch-all in your app.yaml file

- url: /.*
script: my404ErrorPage.py

-nick
On Sep 3, 10:40 am, "Larry.Ches...@googlemail.com"

Larry....@googlemail.com

unread,
Sep 4, 2008, 3:57:55 AM9/4/08
to Google App Engine
Thanks, that's a good idea. Could I do something similar for 500
errors? I would also need to catch other errors in some way too. I
guess I could just shove a try-except block round each handler and
redirect to my 500 error page in the except block, but I wonder if
there is a better way...?

Alexander Kojevnikov

unread,
Sep 4, 2008, 7:17:58 AM9/4/08
to Google App Engine
Add a BaseHandler class and inherit all your request handlers from it.
In the BaseHandler, override the handle_exception() method. The method
is called if an exception is raised in your handler. More info
available in the docs:
http://code.google.com/appengine/docs/webapp/requesthandlerclass.html#RequestHandler_handle_exception

On Sep 4, 6:57 pm, "Larry.Ches...@googlemail.com"

Larry....@googlemail.com

unread,
Sep 4, 2008, 12:06:30 PM9/4/08
to Google App Engine
Perfect! Thanks guys. :)
Reply all
Reply to author
Forward
0 new messages