forked from liberapay/liberapay.com
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherror.spt
42 lines (34 loc) · 1.15 KB
/
error.spt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from __future__ import absolute_import, division, print_function, unicode_literals
from pando.http import status_strings
from liberapay.exceptions import LazyResponse
from liberapay.utils.i18n import HTTP_ERRORS
[----------------------------------------]
code = response.code
msg = _(HTTP_ERRORS.get(code, status_strings.get(code, '')))
try:
assert msg
except Exception as e:
website.tell_sentry(e, state)
if isinstance(response, LazyResponse):
response.render_body(state)
err = response.text
if code == 500 and not err:
err = _("Looks like you've found a bug! Sorry for the inconvenience, we'll get it fixed ASAP!")
[----------------------------------------] text/html
% extends "templates/base.html"
% set title = '' if response.html_template else code
% block content
% if response.html_template
% include response.html_template
% else
<p>{{ msg }}</p>
<pre>{{ err }}</pre>
% endif
% endblock
[----------------------------------------] application/json via json_dump
{ "error_code": code
, "error_message_short": msg
, "error_message_long": err
}
[----------------------------------------] text/plain
{{err or msg}}