Skip to content

Commit

Permalink
[#4801] Align format of flask exceptions with Pylons/webob ones
Browse files Browse the repository at this point in the history
  • Loading branch information
amercader committed Dec 19, 2019
1 parent 6916b7a commit 01481d9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
8 changes: 5 additions & 3 deletions ckan/config/middleware/flask_app.py
Expand Up @@ -464,9 +464,11 @@ def _register_error_handler(app):
def error_handler(e):
log.error(e, exc_info=sys.exc_info)
if isinstance(e, HTTPException):
extra_vars = {u'code': [e.code], u'content': e.description}
# TODO: Remove
g.code = [e.code]
extra_vars = {
u'code': e.code,
u'content': e.description,
u'name': e.name
}

return base.render(
u'error_document_template.html', extra_vars), e.code
Expand Down
2 changes: 1 addition & 1 deletion ckan/controllers/error.py
Expand Up @@ -45,7 +45,7 @@ def document(self):
cgi.escape(request.GET.get('message', ''))
prefix = request.environ.get('SCRIPT_NAME', ''),
code = cgi.escape(request.GET.get('code',
str(original_response.status_int))),
str(original_response.status_int)))
extra_vars = {'code': code, 'content': content, 'prefix': prefix}
return render('error_document_template.html', extra_vars=extra_vars)

Expand Down
5 changes: 4 additions & 1 deletion ckan/templates/error_document_template.html
@@ -1,10 +1,13 @@
{% extends "page.html" %}

{% block subtitle %}{{ gettext('Error %(error_code)s', error_code=code[0]) }}{% endblock %}
{% block subtitle %}{{ gettext('Error %(error_code)s', error_code=code) }}{% endblock %}

{% block primary %}
<article class="module">
<div class="module-content">
{% if name %}
<h1>{{ code }} {{ name }}</h1>
{% endif %}
{{ content}}
</div>
</article>
Expand Down

0 comments on commit 01481d9

Please sign in to comment.