From d3b8fa5e068a90002ef77e9bae8e7d3ec181a2e0 Mon Sep 17 00:00:00 2001 From: Deimos Date: Tue, 19 Feb 2019 15:26:19 -0700 Subject: [PATCH] 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. --- tildes/tildes/views/exceptions.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tildes/tildes/views/exceptions.py b/tildes/tildes/views/exceptions.py index 40ac4b8..7556e1d 100644 --- a/tildes/tildes/views/exceptions.py +++ b/tildes/tildes/views/exceptions.py @@ -3,7 +3,7 @@ """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.view import ( exception_view_config, @@ -35,7 +35,7 @@ def group_not_found(request: Request) -> dict: @notfound_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: """Display a generic error page for all HTTP exceptions.""" request.response.status_int = request.exception.status_int