custom error views #15

Closed
faassen opened this Issue Nov 5, 2013 · 9 comments

Projects

None yet

2 participants

@faassen
Morepath member

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

@webmaven

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

@faassen
Morepath member

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.

@webmaven

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

@faassen
Morepath member

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?

@webmaven

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

@faassen
Morepath member

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!"
@webmaven

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

@faassen
Morepath member

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)>

@faassen
Morepath member

This is implemented now.

@faassen faassen closed this Mar 6, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment