For a Google Appengine project written in Python, I want to have my own error messages when an error occurs. I want to use the error_handlers as described in: http://code.google.com/intl/nl/appengine/docs/python/config/appconfig.html#Custom_Error_Responses
In the application I use webapp with debug = False
When I create an error in my code, I get the standard 500 Server error message from the browser.
I have created a custom error page named default_error.html
The question is: Where to save this custom error page?
BTW This is my app.yaml
code:
application: customerrorpage
version: 1
runtime: python
api_version: 1
error_handlers:
- file: default_error.html
handlers:
- url: /good.htm
static_files: static/good.htm
upload: static/good.htm
- url: /
static_files: static/good.htm
upload: static/good.htm
- url: /.*
script: main.py
Defining a custom 404 with just the python part works for me:
app.error_handlers[404] = handle_404
def handle_404(request, response, exception):
c = {'exception': exception.status}
t = jinja2.get_jinja2(app=app).render_template('404.html', **c)
response.write(t)
response.set_status(exception.status_int)
This gives you more control over error messages and other dynamics that you might want to display.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With