templates_distrosdir = $(templatesdir)/distros
dist_templates_errors_DATA = \
- src/templates/errors/error.html \
- src/templates/errors/error-400.html \
- src/templates/errors/error-403.html \
- src/templates/errors/error-404.html
+ src/templates/errors/error.html
templates_errorsdir = $(templatesdir)/errors
+++ /dev/null
-{% extends "error.html" %}
-
-{% block bigbox_headline %}
- {{ _("400 - Bad request") }}
-{% end block %}
-
-{% block bigbox_subtitle %}
- <small>{{ _("Invalid data has been passed to the application.") }}</small>
-{% end block %}
-
-{% block explanation %}
- <p>
- {{ _("The application refused to go on with the provided data that was sent in this request.") }}
- </p>
-{% end block %}
-
-{% block message %}{% end block %}
+++ /dev/null
-{% extends "error.html" %}
-
-{% block bigbox_headline %}
- {{ _("403 - Access forbidden") }}
-{% end block %}
-
-{% block bigbox_subtitle %}
- <small>{{ _("You are not allowed to access this ressource.") }}</small>
-{% end block %}
-
-{% block explanation %}
- <p>
- {{ _("Access to the requested page has been denied because you do not have sufficient rights.") }}
- </p>
-{% end block %}
-
-{% block message %}{% end block %}
+++ /dev/null
-{% extends "error.html" %}
-
-{% block bigbox_headline %}
- {{ _("404 - Not Found") }}
-{% end block %}
-
-{% block bigbox_subtitle %}
- <small>{{ _("I could not find what you were searching for.") }}</small>
-{% end block %}
-
-{% block explanation %}
- <p>
- {{ _("You may have clicked an expired link or mistyped the address.") }}
- </p>
-{% end block %}
-
-{% block message %}{% end block %}
{{ _("Oops, something is not right...") }}
</p>
<p class="subtitle">
- {{ status_code }} - {{ status_message }}
+ {{ code }} - {{ message }}
</p>
</div>
</div>
</section>
- {% if current_user and current_user.is_admin() and tb %}
+ {% if traceback %}
<section class="section">
<div class="container">
<h4 class="title is-4">{{ _("Exception (Traceback):") }}</h4>
- <pre>{{ "".join(tb) }}</pre>
+ <pre>{{ traceback }}</pre>
</div>
</section>
{% end %}
return ns
- def write_error(self, status_code, exc_info=None, **kwargs):
- if status_code in (400, 403, 404):
- error_document = "errors/error-%s.html" % status_code
- else:
- error_document = "errors/error.html"
-
+ def write_error(self, code, exc_info=None, **kwargs):
try:
- status_message = http.client.responses[status_code]
+ message = http.client.responses[code]
except KeyError:
- status_message = None
+ message = None
+
+ _traceback = []
# Collect more information about the exception if possible.
if exc_info:
- tb = traceback.format_exception(*exc_info)
- else:
- tb = None
+ if self.current_user and self.current_user.is_admin():
+ _traceback += traceback.format_exception(*exc_info)
- self.render(error_document, status_code=status_code,
- status_message=status_message, exc_info=exc_info, tb=tb, **kwargs)
+ self.render("errors/error.html",
+ code=code, message=message, traceback="".join(_traceback), **kwargs)
# Typed Arguments