errorpages: use original http status for rendered error page

This commit is contained in:
Daniel Dourvaris 2016-06-14 08:27:18 +03:00
parent 71a0c66f67
commit c17c69173b

View file

@ -31,9 +31,9 @@ from pyramid.config import Configurator
from pyramid.static import static_view
from pyramid.settings import asbool, aslist
from pyramid.wsgi import wsgiapp
from pyramid.httpexceptions import HTTPError
from pyramid.httpexceptions import HTTPError, HTTPInternalServerError
import pyramid.httpexceptions as httpexceptions
from pyramid.renderers import render_to_response
from pyramid.renderers import render_to_response, render
from routes.middleware import RoutesMiddleware
import routes.util
@ -183,8 +183,15 @@ def error_handler(exc, request):
if not c.rhodecode_name:
c.rhodecode_name = 'Rhodecode'
base_response = HTTPInternalServerError()
# prefer original exception for the response since it may have headers set
if isinstance(exc, HTTPError):
base_response = exc
response = render_to_response(
'/errors/error_document.html', {'c': c}, request=request)
'/errors/error_document.html', {'c': c}, request=request,
response=base_response)
return response