forked from liberapay/liberapay.com
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherror.spt
55 lines (47 loc) · 1.66 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
43
44
45
46
47
48
49
50
51
52
53
54
55
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
[----------------------------------------]
sentry_ident = state.get('sentry_ident')
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>
% if website.show_tracebacks
<pre>{{ err }}</pre>
% else
<div class="alert alert-danger">{{ err }}</div>
% endif
% if sentry_ident
<p>{{ _(
"The details of this error have been recorded. If you decide to contact us "
"please include the following error identification code in your message: {0}.",
'<code>%s</code>'|safe % sentry_ident
) }}</p>
% endif
% endif
% endblock
[----------------------------------------] application/json via json_dump
{ "error_code": code
, "error_message_short": msg
, "error_message_long": err
, "error_id": sentry_ident
}
[----------------------------------------] text/plain
{{err or msg}}