Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

custom error views #15

Closed
faassen opened this Issue · 9 comments

2 participants

Martijn Faassen Michael R. Bernstein
Martijn Faassen
Owner

We need to introduce a system for registering custom error views.

Michael R. Bernstein

By which you mean custom 404 and 503 pages, for example?

Martijn Faassen
Owner

Basically the scenario should be that the application raises an exception, and you catch it, and display a view. This may be a HTTP exception object, so you can do a custom 404, but you could also catch custom exceptions that have meaning to your application.

Michael R. Bernstein

Launchpad.net has some fairly involved error reporting mechanisms that might be cool to integrate or look at for inspiration:
https://launchpad.net/python-oops
https://launchpad.net/python-oops-wsgi
https://launchpad.net/python-oops-tools

Martijn Faassen
Owner

Hm, those oops tools aree interesting but they're unrelated to error views I think. An error view helps you give the capability to show a different user-visible error response. The oops tools are tools you can integrate during deployment that can log errors for you. Care to make a new issue about these oops tools?

Michael R. Bernstein

Sorry, this link should make it more obvious how this interacts with user-visible errors: https://pypi.python.org/pypi/oops_wsgi

The other packages:
https://pypi.python.org/pypi/oops
https://pypi.python.org/pypi/oops-tools

Martijn Faassen
Owner

Ah, oops has a way to customize the error page. But that's not what oops seems to be about; the primary goal seems to be the logging of errors.

Anyway, I was thinking about something like:

@app.view(model=ZeroDivisionError)
def zero_division(self, request):
     return "The application unfortunately suffered from a division by zero!"
Michael R. Bernstein

Ah, Now I see what you were getting at. Very nice!

Martijn Faassen
Owner

I need to do some investigation in how I can retain the HTTP error of the exception already raised in the new response object the view returns (if it's something from werkzeug.exceptions)>

Martijn Faassen
Owner

This is implemented now.

Martijn Faassen faassen closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.