Browse Source

Error page: cover HTTPError, not HTTPException

HTTPException hits all HTTP codes, including redirections, which was
breaking the tild.es shortener. Using HTTPError instead will only cover
the 4xx and 5xx codes, which is what we want.
merge-requests/60/head
Deimos 6 years ago
parent
commit
d3b8fa5e06
  1. 4
      tildes/tildes/views/exceptions.py

4
tildes/tildes/views/exceptions.py

@ -3,7 +3,7 @@
"""Views used by Pyramid when an exception is raised.""" """Views used by Pyramid when an exception is raised."""
from pyramid.httpexceptions import HTTPException, HTTPForbidden, HTTPNotFound
from pyramid.httpexceptions import HTTPError, HTTPForbidden, HTTPNotFound
from pyramid.request import Request from pyramid.request import Request
from pyramid.view import ( from pyramid.view import (
exception_view_config, exception_view_config,
@ -35,7 +35,7 @@ def group_not_found(request: Request) -> dict:
@notfound_view_config(xhr=False, renderer="error_page.jinja2") @notfound_view_config(xhr=False, renderer="error_page.jinja2")
@forbidden_view_config(xhr=False, renderer="error_page.jinja2") @forbidden_view_config(xhr=False, renderer="error_page.jinja2")
@exception_view_config(context=HTTPException, xhr=False, renderer="error_page.jinja2")
@exception_view_config(context=HTTPError, xhr=False, renderer="error_page.jinja2")
def generic_error_page(request: Request) -> dict: def generic_error_page(request: Request) -> dict:
"""Display a generic error page for all HTTP exceptions.""" """Display a generic error page for all HTTP exceptions."""
request.response.status_int = request.exception.status_int request.response.status_int = request.exception.status_int

Loading…
Cancel
Save