author | Tero Marttila <terom@fixme.fi> |
Sun, 13 Sep 2009 18:47:00 +0300 | |
changeset 141 | 65c98c9e1716 |
parent 140 | 6db2527b67cf |
permissions | -rw-r--r-- |
134
fbccc1648d79
improved error handling for CGI/FastCGI
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
1 |
""" |
fbccc1648d79
improved error handling for CGI/FastCGI
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
2 |
Build error messages |
fbccc1648d79
improved error handling for CGI/FastCGI
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
3 |
""" |
fbccc1648d79
improved error handling for CGI/FastCGI
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
4 |
|
135
19ff083c2870
pimp mah error messages, it has a full link to the Trac with pre-filled title, traceback, url, hg revision fields
Tero Marttila <terom@fixme.fi>
parents:
134
diff
changeset
|
5 |
import traceback, sys, cgi, urllib |
134
fbccc1648d79
improved error handling for CGI/FastCGI
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
6 |
|
136
c69a176b3620
better string truncation for error messages
Tero Marttila <terom@fixme.fi>
parents:
135
diff
changeset
|
7 |
def truncate (msg, limit) : |
c69a176b3620
better string truncation for error messages
Tero Marttila <terom@fixme.fi>
parents:
135
diff
changeset
|
8 |
""" |
c69a176b3620
better string truncation for error messages
Tero Marttila <terom@fixme.fi>
parents:
135
diff
changeset
|
9 |
Truncate the given message to <limit> chars |
c69a176b3620
better string truncation for error messages
Tero Marttila <terom@fixme.fi>
parents:
135
diff
changeset
|
10 |
""" |
c69a176b3620
better string truncation for error messages
Tero Marttila <terom@fixme.fi>
parents:
135
diff
changeset
|
11 |
|
c69a176b3620
better string truncation for error messages
Tero Marttila <terom@fixme.fi>
parents:
135
diff
changeset
|
12 |
if len(msg) > limit : |
c69a176b3620
better string truncation for error messages
Tero Marttila <terom@fixme.fi>
parents:
135
diff
changeset
|
13 |
return msg[:limit-3] + '...' |
c69a176b3620
better string truncation for error messages
Tero Marttila <terom@fixme.fi>
parents:
135
diff
changeset
|
14 |
|
c69a176b3620
better string truncation for error messages
Tero Marttila <terom@fixme.fi>
parents:
135
diff
changeset
|
15 |
else : |
c69a176b3620
better string truncation for error messages
Tero Marttila <terom@fixme.fi>
parents:
135
diff
changeset
|
16 |
return msg |
c69a176b3620
better string truncation for error messages
Tero Marttila <terom@fixme.fi>
parents:
135
diff
changeset
|
17 |
|
137
a25d1bf758e6
moar pimping of the error page... at this point, error messages are becoming more of a feature than a bug
Tero Marttila <terom@fixme.fi>
parents:
136
diff
changeset
|
18 |
def build_link (title, url) : |
a25d1bf758e6
moar pimping of the error page... at this point, error messages are becoming more of a feature than a bug
Tero Marttila <terom@fixme.fi>
parents:
136
diff
changeset
|
19 |
return '<a href="%s">%s</a>' % (cgi.escape(url, True), cgi.escape(title)) |
a25d1bf758e6
moar pimping of the error page... at this point, error messages are becoming more of a feature than a bug
Tero Marttila <terom@fixme.fi>
parents:
136
diff
changeset
|
20 |
|
135
19ff083c2870
pimp mah error messages, it has a full link to the Trac with pre-filled title, traceback, url, hg revision fields
Tero Marttila <terom@fixme.fi>
parents:
134
diff
changeset
|
21 |
def build_error (exc_info=None, env=None) : |
134
fbccc1648d79
improved error handling for CGI/FastCGI
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
22 |
""" |
fbccc1648d79
improved error handling for CGI/FastCGI
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
23 |
Dumps out a raw traceback of the given/current exception to stdout. |
fbccc1648d79
improved error handling for CGI/FastCGI
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
24 |
|
135
19ff083c2870
pimp mah error messages, it has a full link to the Trac with pre-filled title, traceback, url, hg revision fields
Tero Marttila <terom@fixme.fi>
parents:
134
diff
changeset
|
25 |
If request_env, it should be a environment dict, like under WSGI, and will be used to display additional info |
19ff083c2870
pimp mah error messages, it has a full link to the Trac with pre-filled title, traceback, url, hg revision fields
Tero Marttila <terom@fixme.fi>
parents:
134
diff
changeset
|
26 |
about the request. |
19ff083c2870
pimp mah error messages, it has a full link to the Trac with pre-filled title, traceback, url, hg revision fields
Tero Marttila <terom@fixme.fi>
parents:
134
diff
changeset
|
27 |
|
134
fbccc1648d79
improved error handling for CGI/FastCGI
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
28 |
Returns a (status, content-type, body) tuple, with all components being non-unicode strs. |
fbccc1648d79
improved error handling for CGI/FastCGI
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
29 |
""" |
fbccc1648d79
improved error handling for CGI/FastCGI
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
30 |
|
135
19ff083c2870
pimp mah error messages, it has a full link to the Trac with pre-filled title, traceback, url, hg revision fields
Tero Marttila <terom@fixme.fi>
parents:
134
diff
changeset
|
31 |
# default for exc_info is current exception |
134
fbccc1648d79
improved error handling for CGI/FastCGI
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
32 |
if not exc_info : |
fbccc1648d79
improved error handling for CGI/FastCGI
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
33 |
exc_info = sys.exc_info() |
fbccc1648d79
improved error handling for CGI/FastCGI
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
34 |
|
135
19ff083c2870
pimp mah error messages, it has a full link to the Trac with pre-filled title, traceback, url, hg revision fields
Tero Marttila <terom@fixme.fi>
parents:
134
diff
changeset
|
35 |
# request URL? |
19ff083c2870
pimp mah error messages, it has a full link to the Trac with pre-filled title, traceback, url, hg revision fields
Tero Marttila <terom@fixme.fi>
parents:
134
diff
changeset
|
36 |
if env : |
19ff083c2870
pimp mah error messages, it has a full link to the Trac with pre-filled title, traceback, url, hg revision fields
Tero Marttila <terom@fixme.fi>
parents:
134
diff
changeset
|
37 |
try : |
19ff083c2870
pimp mah error messages, it has a full link to the Trac with pre-filled title, traceback, url, hg revision fields
Tero Marttila <terom@fixme.fi>
parents:
134
diff
changeset
|
38 |
from qmsk.web.http import request_url |
19ff083c2870
pimp mah error messages, it has a full link to the Trac with pre-filled title, traceback, url, hg revision fields
Tero Marttila <terom@fixme.fi>
parents:
134
diff
changeset
|
39 |
|
19ff083c2870
pimp mah error messages, it has a full link to the Trac with pre-filled title, traceback, url, hg revision fields
Tero Marttila <terom@fixme.fi>
parents:
134
diff
changeset
|
40 |
url = request_url(env) |
19ff083c2870
pimp mah error messages, it has a full link to the Trac with pre-filled title, traceback, url, hg revision fields
Tero Marttila <terom@fixme.fi>
parents:
134
diff
changeset
|
41 |
|
19ff083c2870
pimp mah error messages, it has a full link to the Trac with pre-filled title, traceback, url, hg revision fields
Tero Marttila <terom@fixme.fi>
parents:
134
diff
changeset
|
42 |
except : |
19ff083c2870
pimp mah error messages, it has a full link to the Trac with pre-filled title, traceback, url, hg revision fields
Tero Marttila <terom@fixme.fi>
parents:
134
diff
changeset
|
43 |
# ignore |
19ff083c2870
pimp mah error messages, it has a full link to the Trac with pre-filled title, traceback, url, hg revision fields
Tero Marttila <terom@fixme.fi>
parents:
134
diff
changeset
|
44 |
url = None |
19ff083c2870
pimp mah error messages, it has a full link to the Trac with pre-filled title, traceback, url, hg revision fields
Tero Marttila <terom@fixme.fi>
parents:
134
diff
changeset
|
45 |
else : |
19ff083c2870
pimp mah error messages, it has a full link to the Trac with pre-filled title, traceback, url, hg revision fields
Tero Marttila <terom@fixme.fi>
parents:
134
diff
changeset
|
46 |
url = None |
19ff083c2870
pimp mah error messages, it has a full link to the Trac with pre-filled title, traceback, url, hg revision fields
Tero Marttila <terom@fixme.fi>
parents:
134
diff
changeset
|
47 |
|
19ff083c2870
pimp mah error messages, it has a full link to the Trac with pre-filled title, traceback, url, hg revision fields
Tero Marttila <terom@fixme.fi>
parents:
134
diff
changeset
|
48 |
# working copy path? |
19ff083c2870
pimp mah error messages, it has a full link to the Trac with pre-filled title, traceback, url, hg revision fields
Tero Marttila <terom@fixme.fi>
parents:
134
diff
changeset
|
49 |
try : |
137
a25d1bf758e6
moar pimping of the error page... at this point, error messages are becoming more of a feature than a bug
Tero Marttila <terom@fixme.fi>
parents:
136
diff
changeset
|
50 |
from config import HG_WC_PATH, HGWEB_URL |
135
19ff083c2870
pimp mah error messages, it has a full link to the Trac with pre-filled title, traceback, url, hg revision fields
Tero Marttila <terom@fixme.fi>
parents:
134
diff
changeset
|
51 |
|
19ff083c2870
pimp mah error messages, it has a full link to the Trac with pre-filled title, traceback, url, hg revision fields
Tero Marttila <terom@fixme.fi>
parents:
134
diff
changeset
|
52 |
wc_path = HG_WC_PATH |
137
a25d1bf758e6
moar pimping of the error page... at this point, error messages are becoming more of a feature than a bug
Tero Marttila <terom@fixme.fi>
parents:
136
diff
changeset
|
53 |
hgweb_url = HGWEB_URL |
135
19ff083c2870
pimp mah error messages, it has a full link to the Trac with pre-filled title, traceback, url, hg revision fields
Tero Marttila <terom@fixme.fi>
parents:
134
diff
changeset
|
54 |
|
19ff083c2870
pimp mah error messages, it has a full link to the Trac with pre-filled title, traceback, url, hg revision fields
Tero Marttila <terom@fixme.fi>
parents:
134
diff
changeset
|
55 |
except : |
19ff083c2870
pimp mah error messages, it has a full link to the Trac with pre-filled title, traceback, url, hg revision fields
Tero Marttila <terom@fixme.fi>
parents:
134
diff
changeset
|
56 |
# a good guess |
19ff083c2870
pimp mah error messages, it has a full link to the Trac with pre-filled title, traceback, url, hg revision fields
Tero Marttila <terom@fixme.fi>
parents:
134
diff
changeset
|
57 |
wc_path = '.' |
137
a25d1bf758e6
moar pimping of the error page... at this point, error messages are becoming more of a feature than a bug
Tero Marttila <terom@fixme.fi>
parents:
136
diff
changeset
|
58 |
hgweb_url = None |
135
19ff083c2870
pimp mah error messages, it has a full link to the Trac with pre-filled title, traceback, url, hg revision fields
Tero Marttila <terom@fixme.fi>
parents:
134
diff
changeset
|
59 |
|
19ff083c2870
pimp mah error messages, it has a full link to the Trac with pre-filled title, traceback, url, hg revision fields
Tero Marttila <terom@fixme.fi>
parents:
134
diff
changeset
|
60 |
# version? |
19ff083c2870
pimp mah error messages, it has a full link to the Trac with pre-filled title, traceback, url, hg revision fields
Tero Marttila <terom@fixme.fi>
parents:
134
diff
changeset
|
61 |
try : |
137
a25d1bf758e6
moar pimping of the error page... at this point, error messages are becoming more of a feature than a bug
Tero Marttila <terom@fixme.fi>
parents:
136
diff
changeset
|
62 |
from version import version_string, version_link_hg |
135
19ff083c2870
pimp mah error messages, it has a full link to the Trac with pre-filled title, traceback, url, hg revision fields
Tero Marttila <terom@fixme.fi>
parents:
134
diff
changeset
|
63 |
|
19ff083c2870
pimp mah error messages, it has a full link to the Trac with pre-filled title, traceback, url, hg revision fields
Tero Marttila <terom@fixme.fi>
parents:
134
diff
changeset
|
64 |
version = version_string(wc_path) |
137
a25d1bf758e6
moar pimping of the error page... at this point, error messages are becoming more of a feature than a bug
Tero Marttila <terom@fixme.fi>
parents:
136
diff
changeset
|
65 |
|
a25d1bf758e6
moar pimping of the error page... at this point, error messages are becoming more of a feature than a bug
Tero Marttila <terom@fixme.fi>
parents:
136
diff
changeset
|
66 |
if hgweb_url : |
139
9c7769850195
fix error.py version_link_hg argument order
Tero Marttila <terom@fixme.fi>
parents:
137
diff
changeset
|
67 |
version_href = version_link_hg(hgweb_url, wc_path) |
137
a25d1bf758e6
moar pimping of the error page... at this point, error messages are becoming more of a feature than a bug
Tero Marttila <terom@fixme.fi>
parents:
136
diff
changeset
|
68 |
|
a25d1bf758e6
moar pimping of the error page... at this point, error messages are becoming more of a feature than a bug
Tero Marttila <terom@fixme.fi>
parents:
136
diff
changeset
|
69 |
else : |
a25d1bf758e6
moar pimping of the error page... at this point, error messages are becoming more of a feature than a bug
Tero Marttila <terom@fixme.fi>
parents:
136
diff
changeset
|
70 |
version_href = None |
135
19ff083c2870
pimp mah error messages, it has a full link to the Trac with pre-filled title, traceback, url, hg revision fields
Tero Marttila <terom@fixme.fi>
parents:
134
diff
changeset
|
71 |
|
19ff083c2870
pimp mah error messages, it has a full link to the Trac with pre-filled title, traceback, url, hg revision fields
Tero Marttila <terom@fixme.fi>
parents:
134
diff
changeset
|
72 |
except : |
19ff083c2870
pimp mah error messages, it has a full link to the Trac with pre-filled title, traceback, url, hg revision fields
Tero Marttila <terom@fixme.fi>
parents:
134
diff
changeset
|
73 |
version = None |
137
a25d1bf758e6
moar pimping of the error page... at this point, error messages are becoming more of a feature than a bug
Tero Marttila <terom@fixme.fi>
parents:
136
diff
changeset
|
74 |
version_href = None |
135
19ff083c2870
pimp mah error messages, it has a full link to the Trac with pre-filled title, traceback, url, hg revision fields
Tero Marttila <terom@fixme.fi>
parents:
134
diff
changeset
|
75 |
|
19ff083c2870
pimp mah error messages, it has a full link to the Trac with pre-filled title, traceback, url, hg revision fields
Tero Marttila <terom@fixme.fi>
parents:
134
diff
changeset
|
76 |
# the exception type |
136
c69a176b3620
better string truncation for error messages
Tero Marttila <terom@fixme.fi>
parents:
135
diff
changeset
|
77 |
exception_str = traceback.format_exception_only(*exc_info[:2])[-1] |
135
19ff083c2870
pimp mah error messages, it has a full link to the Trac with pre-filled title, traceback, url, hg revision fields
Tero Marttila <terom@fixme.fi>
parents:
134
diff
changeset
|
78 |
|
19ff083c2870
pimp mah error messages, it has a full link to the Trac with pre-filled title, traceback, url, hg revision fields
Tero Marttila <terom@fixme.fi>
parents:
134
diff
changeset
|
79 |
# the exception traceback |
19ff083c2870
pimp mah error messages, it has a full link to the Trac with pre-filled title, traceback, url, hg revision fields
Tero Marttila <terom@fixme.fi>
parents:
134
diff
changeset
|
80 |
traceback_lines = traceback.format_exception(*exc_info) |
19ff083c2870
pimp mah error messages, it has a full link to the Trac with pre-filled title, traceback, url, hg revision fields
Tero Marttila <terom@fixme.fi>
parents:
134
diff
changeset
|
81 |
|
19ff083c2870
pimp mah error messages, it has a full link to the Trac with pre-filled title, traceback, url, hg revision fields
Tero Marttila <terom@fixme.fi>
parents:
134
diff
changeset
|
82 |
# XXX: make this configureable |
19ff083c2870
pimp mah error messages, it has a full link to the Trac with pre-filled title, traceback, url, hg revision fields
Tero Marttila <terom@fixme.fi>
parents:
134
diff
changeset
|
83 |
trac_url = "http://projects.qmsk.net/irclogs2/trac" |
19ff083c2870
pimp mah error messages, it has a full link to the Trac with pre-filled title, traceback, url, hg revision fields
Tero Marttila <terom@fixme.fi>
parents:
134
diff
changeset
|
84 |
|
19ff083c2870
pimp mah error messages, it has a full link to the Trac with pre-filled title, traceback, url, hg revision fields
Tero Marttila <terom@fixme.fi>
parents:
134
diff
changeset
|
85 |
# ticket list |
137
a25d1bf758e6
moar pimping of the error page... at this point, error messages are becoming more of a feature than a bug
Tero Marttila <terom@fixme.fi>
parents:
136
diff
changeset
|
86 |
trac_query = build_link("All tickets", "%s/query" % trac_url) |
135
19ff083c2870
pimp mah error messages, it has a full link to the Trac with pre-filled title, traceback, url, hg revision fields
Tero Marttila <terom@fixme.fi>
parents:
134
diff
changeset
|
87 |
|
19ff083c2870
pimp mah error messages, it has a full link to the Trac with pre-filled title, traceback, url, hg revision fields
Tero Marttila <terom@fixme.fi>
parents:
134
diff
changeset
|
88 |
# submit ticket |
19ff083c2870
pimp mah error messages, it has a full link to the Trac with pre-filled title, traceback, url, hg revision fields
Tero Marttila <terom@fixme.fi>
parents:
134
diff
changeset
|
89 |
submit_args = dict(type='defect') |
137
a25d1bf758e6
moar pimping of the error page... at this point, error messages are becoming more of a feature than a bug
Tero Marttila <terom@fixme.fi>
parents:
136
diff
changeset
|
90 |
|
a25d1bf758e6
moar pimping of the error page... at this point, error messages are becoming more of a feature than a bug
Tero Marttila <terom@fixme.fi>
parents:
136
diff
changeset
|
91 |
# handle optional components |
135
19ff083c2870
pimp mah error messages, it has a full link to the Trac with pre-filled title, traceback, url, hg revision fields
Tero Marttila <terom@fixme.fi>
parents:
134
diff
changeset
|
92 |
if url : |
19ff083c2870
pimp mah error messages, it has a full link to the Trac with pre-filled title, traceback, url, hg revision fields
Tero Marttila <terom@fixme.fi>
parents:
134
diff
changeset
|
93 |
submit_args['url'] = url |
137
a25d1bf758e6
moar pimping of the error page... at this point, error messages are becoming more of a feature than a bug
Tero Marttila <terom@fixme.fi>
parents:
136
diff
changeset
|
94 |
trac_query_url = build_link("Same URL", "%s/query?url=%s" % (trac_url, urllib.quote(url))) |
a25d1bf758e6
moar pimping of the error page... at this point, error messages are becoming more of a feature than a bug
Tero Marttila <terom@fixme.fi>
parents:
136
diff
changeset
|
95 |
else : |
a25d1bf758e6
moar pimping of the error page... at this point, error messages are becoming more of a feature than a bug
Tero Marttila <terom@fixme.fi>
parents:
136
diff
changeset
|
96 |
trac_query_url = "" |
a25d1bf758e6
moar pimping of the error page... at this point, error messages are becoming more of a feature than a bug
Tero Marttila <terom@fixme.fi>
parents:
136
diff
changeset
|
97 |
|
135
19ff083c2870
pimp mah error messages, it has a full link to the Trac with pre-filled title, traceback, url, hg revision fields
Tero Marttila <terom@fixme.fi>
parents:
134
diff
changeset
|
98 |
if version : |
19ff083c2870
pimp mah error messages, it has a full link to the Trac with pre-filled title, traceback, url, hg revision fields
Tero Marttila <terom@fixme.fi>
parents:
134
diff
changeset
|
99 |
submit_args['revision'] = version |
137
a25d1bf758e6
moar pimping of the error page... at this point, error messages are becoming more of a feature than a bug
Tero Marttila <terom@fixme.fi>
parents:
136
diff
changeset
|
100 |
trac_query_version = build_link("Same version", "%s/query?revision=%s" % (trac_url, urllib.quote(version))) |
a25d1bf758e6
moar pimping of the error page... at this point, error messages are becoming more of a feature than a bug
Tero Marttila <terom@fixme.fi>
parents:
136
diff
changeset
|
101 |
|
a25d1bf758e6
moar pimping of the error page... at this point, error messages are becoming more of a feature than a bug
Tero Marttila <terom@fixme.fi>
parents:
136
diff
changeset
|
102 |
else : |
a25d1bf758e6
moar pimping of the error page... at this point, error messages are becoming more of a feature than a bug
Tero Marttila <terom@fixme.fi>
parents:
136
diff
changeset
|
103 |
trac_query_version = "" |
135
19ff083c2870
pimp mah error messages, it has a full link to the Trac with pre-filled title, traceback, url, hg revision fields
Tero Marttila <terom@fixme.fi>
parents:
134
diff
changeset
|
104 |
|
19ff083c2870
pimp mah error messages, it has a full link to the Trac with pre-filled title, traceback, url, hg revision fields
Tero Marttila <terom@fixme.fi>
parents:
134
diff
changeset
|
105 |
if exception_str : |
136
c69a176b3620
better string truncation for error messages
Tero Marttila <terom@fixme.fi>
parents:
135
diff
changeset
|
106 |
submit_args['summary'] = truncate(exception_str, 140) |
137
a25d1bf758e6
moar pimping of the error page... at this point, error messages are becoming more of a feature than a bug
Tero Marttila <terom@fixme.fi>
parents:
136
diff
changeset
|
107 |
trac_query_err = build_link("Same error", "%s/query?summary=%s" % (trac_url, urllib.quote(exception_str.rstrip()))) |
a25d1bf758e6
moar pimping of the error page... at this point, error messages are becoming more of a feature than a bug
Tero Marttila <terom@fixme.fi>
parents:
136
diff
changeset
|
108 |
|
a25d1bf758e6
moar pimping of the error page... at this point, error messages are becoming more of a feature than a bug
Tero Marttila <terom@fixme.fi>
parents:
136
diff
changeset
|
109 |
else : |
a25d1bf758e6
moar pimping of the error page... at this point, error messages are becoming more of a feature than a bug
Tero Marttila <terom@fixme.fi>
parents:
136
diff
changeset
|
110 |
trac_query_err = "" |
135
19ff083c2870
pimp mah error messages, it has a full link to the Trac with pre-filled title, traceback, url, hg revision fields
Tero Marttila <terom@fixme.fi>
parents:
134
diff
changeset
|
111 |
|
19ff083c2870
pimp mah error messages, it has a full link to the Trac with pre-filled title, traceback, url, hg revision fields
Tero Marttila <terom@fixme.fi>
parents:
134
diff
changeset
|
112 |
if traceback_lines : |
19ff083c2870
pimp mah error messages, it has a full link to the Trac with pre-filled title, traceback, url, hg revision fields
Tero Marttila <terom@fixme.fi>
parents:
134
diff
changeset
|
113 |
# this is big |
19ff083c2870
pimp mah error messages, it has a full link to the Trac with pre-filled title, traceback, url, hg revision fields
Tero Marttila <terom@fixme.fi>
parents:
134
diff
changeset
|
114 |
submit_args['description'] = """\ |
19ff083c2870
pimp mah error messages, it has a full link to the Trac with pre-filled title, traceback, url, hg revision fields
Tero Marttila <terom@fixme.fi>
parents:
134
diff
changeset
|
115 |
[Insert any additional information here] |
19ff083c2870
pimp mah error messages, it has a full link to the Trac with pre-filled title, traceback, url, hg revision fields
Tero Marttila <terom@fixme.fi>
parents:
134
diff
changeset
|
116 |
|
19ff083c2870
pimp mah error messages, it has a full link to the Trac with pre-filled title, traceback, url, hg revision fields
Tero Marttila <terom@fixme.fi>
parents:
134
diff
changeset
|
117 |
|
19ff083c2870
pimp mah error messages, it has a full link to the Trac with pre-filled title, traceback, url, hg revision fields
Tero Marttila <terom@fixme.fi>
parents:
134
diff
changeset
|
118 |
= Traceback = |
19ff083c2870
pimp mah error messages, it has a full link to the Trac with pre-filled title, traceback, url, hg revision fields
Tero Marttila <terom@fixme.fi>
parents:
134
diff
changeset
|
119 |
{{{ |
19ff083c2870
pimp mah error messages, it has a full link to the Trac with pre-filled title, traceback, url, hg revision fields
Tero Marttila <terom@fixme.fi>
parents:
134
diff
changeset
|
120 |
%s |
19ff083c2870
pimp mah error messages, it has a full link to the Trac with pre-filled title, traceback, url, hg revision fields
Tero Marttila <terom@fixme.fi>
parents:
134
diff
changeset
|
121 |
}}}""" % ''.join(traceback_lines) |
19ff083c2870
pimp mah error messages, it has a full link to the Trac with pre-filled title, traceback, url, hg revision fields
Tero Marttila <terom@fixme.fi>
parents:
134
diff
changeset
|
122 |
|
19ff083c2870
pimp mah error messages, it has a full link to the Trac with pre-filled title, traceback, url, hg revision fields
Tero Marttila <terom@fixme.fi>
parents:
134
diff
changeset
|
123 |
# the trac newticket URL |
19ff083c2870
pimp mah error messages, it has a full link to the Trac with pre-filled title, traceback, url, hg revision fields
Tero Marttila <terom@fixme.fi>
parents:
134
diff
changeset
|
124 |
submit_url = "%s/newticket?%s" % (trac_url, '&'.join('%s=%s' % (urllib.quote(k), urllib.quote(v)) for k, v in submit_args.iteritems())) |
19ff083c2870
pimp mah error messages, it has a full link to the Trac with pre-filled title, traceback, url, hg revision fields
Tero Marttila <terom@fixme.fi>
parents:
134
diff
changeset
|
125 |
|
134
fbccc1648d79
improved error handling for CGI/FastCGI
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
126 |
# return |
fbccc1648d79
improved error handling for CGI/FastCGI
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
127 |
return ('500 Internal Server Error', 'text/html; charset=UTF-8', ("""\ |
fbccc1648d79
improved error handling for CGI/FastCGI
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
128 |
<html><head><title>500 Internal Server Error</title></head><body> |
fbccc1648d79
improved error handling for CGI/FastCGI
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
129 |
<h1>Oops!</h1> |
fbccc1648d79
improved error handling for CGI/FastCGI
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
130 |
<p> |
137
a25d1bf758e6
moar pimping of the error page... at this point, error messages are becoming more of a feature than a bug
Tero Marttila <terom@fixme.fi>
parents:
136
diff
changeset
|
131 |
An error occured, which was not logged, and was not reported to anybody. It might be your fault, or it might be mine. |
134
fbccc1648d79
improved error handling for CGI/FastCGI
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
132 |
</p> |
137
a25d1bf758e6
moar pimping of the error page... at this point, error messages are becoming more of a feature than a bug
Tero Marttila <terom@fixme.fi>
parents:
136
diff
changeset
|
133 |
|
134
fbccc1648d79
improved error handling for CGI/FastCGI
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
134 |
<p> |
137
a25d1bf758e6
moar pimping of the error page... at this point, error messages are becoming more of a feature than a bug
Tero Marttila <terom@fixme.fi>
parents:
136
diff
changeset
|
135 |
You can try: |
a25d1bf758e6
moar pimping of the error page... at this point, error messages are becoming more of a feature than a bug
Tero Marttila <terom@fixme.fi>
parents:
136
diff
changeset
|
136 |
<ol style="list-style-type: lower-alpha"> |
a25d1bf758e6
moar pimping of the error page... at this point, error messages are becoming more of a feature than a bug
Tero Marttila <terom@fixme.fi>
parents:
136
diff
changeset
|
137 |
<li><strong>Poking</strong> the administrator of this site to see if they respond</li> |
a25d1bf758e6
moar pimping of the error page... at this point, error messages are becoming more of a feature than a bug
Tero Marttila <terom@fixme.fi>
parents:
136
diff
changeset
|
138 |
<li><strong>Looking</strong> for similar issue tickets with: |
a25d1bf758e6
moar pimping of the error page... at this point, error messages are becoming more of a feature than a bug
Tero Marttila <terom@fixme.fi>
parents:
136
diff
changeset
|
139 |
<ul> |
a25d1bf758e6
moar pimping of the error page... at this point, error messages are becoming more of a feature than a bug
Tero Marttila <terom@fixme.fi>
parents:
136
diff
changeset
|
140 |
<li>%(trac_query)s</li> |
a25d1bf758e6
moar pimping of the error page... at this point, error messages are becoming more of a feature than a bug
Tero Marttila <terom@fixme.fi>
parents:
136
diff
changeset
|
141 |
<li>%(trac_query_url)s</li> |
a25d1bf758e6
moar pimping of the error page... at this point, error messages are becoming more of a feature than a bug
Tero Marttila <terom@fixme.fi>
parents:
136
diff
changeset
|
142 |
<li>%(trac_query_version)s</li> |
a25d1bf758e6
moar pimping of the error page... at this point, error messages are becoming more of a feature than a bug
Tero Marttila <terom@fixme.fi>
parents:
136
diff
changeset
|
143 |
<li>%(trac_query_err)s</li> |
a25d1bf758e6
moar pimping of the error page... at this point, error messages are becoming more of a feature than a bug
Tero Marttila <terom@fixme.fi>
parents:
136
diff
changeset
|
144 |
</ul> |
a25d1bf758e6
moar pimping of the error page... at this point, error messages are becoming more of a feature than a bug
Tero Marttila <terom@fixme.fi>
parents:
136
diff
changeset
|
145 |
</li> |
a25d1bf758e6
moar pimping of the error page... at this point, error messages are becoming more of a feature than a bug
Tero Marttila <terom@fixme.fi>
parents:
136
diff
changeset
|
146 |
<li><strong>Submitting</strong> a new ticket using the following link (quick & easy):</li> |
a25d1bf758e6
moar pimping of the error page... at this point, error messages are becoming more of a feature than a bug
Tero Marttila <terom@fixme.fi>
parents:
136
diff
changeset
|
147 |
</ol> |
134
fbccc1648d79
improved error handling for CGI/FastCGI
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
148 |
</p> |
135
19ff083c2870
pimp mah error messages, it has a full link to the Trac with pre-filled title, traceback, url, hg revision fields
Tero Marttila <terom@fixme.fi>
parents:
134
diff
changeset
|
149 |
<pre> |
19ff083c2870
pimp mah error messages, it has a full link to the Trac with pre-filled title, traceback, url, hg revision fields
Tero Marttila <terom@fixme.fi>
parents:
134
diff
changeset
|
150 |
<a href="%(submit_url)s">%(submit_url_short)s</a> |
19ff083c2870
pimp mah error messages, it has a full link to the Trac with pre-filled title, traceback, url, hg revision fields
Tero Marttila <terom@fixme.fi>
parents:
134
diff
changeset
|
151 |
</pre> |
137
a25d1bf758e6
moar pimping of the error page... at this point, error messages are becoming more of a feature than a bug
Tero Marttila <terom@fixme.fi>
parents:
136
diff
changeset
|
152 |
|
134
fbccc1648d79
improved error handling for CGI/FastCGI
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
153 |
<h2>Details:</h2> |
137
a25d1bf758e6
moar pimping of the error page... at this point, error messages are becoming more of a feature than a bug
Tero Marttila <terom@fixme.fi>
parents:
136
diff
changeset
|
154 |
<p>The page you tried to request was:</p> |
a25d1bf758e6
moar pimping of the error page... at this point, error messages are becoming more of a feature than a bug
Tero Marttila <terom@fixme.fi>
parents:
136
diff
changeset
|
155 |
<pre> |
a25d1bf758e6
moar pimping of the error page... at this point, error messages are becoming more of a feature than a bug
Tero Marttila <terom@fixme.fi>
parents:
136
diff
changeset
|
156 |
%(url)s |
a25d1bf758e6
moar pimping of the error page... at this point, error messages are becoming more of a feature than a bug
Tero Marttila <terom@fixme.fi>
parents:
136
diff
changeset
|
157 |
</pre> |
a25d1bf758e6
moar pimping of the error page... at this point, error messages are becoming more of a feature than a bug
Tero Marttila <terom@fixme.fi>
parents:
136
diff
changeset
|
158 |
|
a25d1bf758e6
moar pimping of the error page... at this point, error messages are becoming more of a feature than a bug
Tero Marttila <terom@fixme.fi>
parents:
136
diff
changeset
|
159 |
<p>The software version is:</p> |
a25d1bf758e6
moar pimping of the error page... at this point, error messages are becoming more of a feature than a bug
Tero Marttila <terom@fixme.fi>
parents:
136
diff
changeset
|
160 |
<pre> |
a25d1bf758e6
moar pimping of the error page... at this point, error messages are becoming more of a feature than a bug
Tero Marttila <terom@fixme.fi>
parents:
136
diff
changeset
|
161 |
%(version_link)s |
a25d1bf758e6
moar pimping of the error page... at this point, error messages are becoming more of a feature than a bug
Tero Marttila <terom@fixme.fi>
parents:
136
diff
changeset
|
162 |
</pre> |
a25d1bf758e6
moar pimping of the error page... at this point, error messages are becoming more of a feature than a bug
Tero Marttila <terom@fixme.fi>
parents:
136
diff
changeset
|
163 |
|
a25d1bf758e6
moar pimping of the error page... at this point, error messages are becoming more of a feature than a bug
Tero Marttila <terom@fixme.fi>
parents:
136
diff
changeset
|
164 |
<p>The error was:</p> |
a25d1bf758e6
moar pimping of the error page... at this point, error messages are becoming more of a feature than a bug
Tero Marttila <terom@fixme.fi>
parents:
136
diff
changeset
|
165 |
<pre> |
a25d1bf758e6
moar pimping of the error page... at this point, error messages are becoming more of a feature than a bug
Tero Marttila <terom@fixme.fi>
parents:
136
diff
changeset
|
166 |
%(exception)s |
a25d1bf758e6
moar pimping of the error page... at this point, error messages are becoming more of a feature than a bug
Tero Marttila <terom@fixme.fi>
parents:
136
diff
changeset
|
167 |
</pre> |
a25d1bf758e6
moar pimping of the error page... at this point, error messages are becoming more of a feature than a bug
Tero Marttila <terom@fixme.fi>
parents:
136
diff
changeset
|
168 |
|
a25d1bf758e6
moar pimping of the error page... at this point, error messages are becoming more of a feature than a bug
Tero Marttila <terom@fixme.fi>
parents:
136
diff
changeset
|
169 |
<p>The traceback was:</p> |
134
fbccc1648d79
improved error handling for CGI/FastCGI
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
170 |
<pre>%(traceback)s</pre> |
fbccc1648d79
improved error handling for CGI/FastCGI
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
171 |
</body></html>""" % dict( |
137
a25d1bf758e6
moar pimping of the error page... at this point, error messages are becoming more of a feature than a bug
Tero Marttila <terom@fixme.fi>
parents:
136
diff
changeset
|
172 |
url = url if url else 'Unknown', |
a25d1bf758e6
moar pimping of the error page... at this point, error messages are becoming more of a feature than a bug
Tero Marttila <terom@fixme.fi>
parents:
136
diff
changeset
|
173 |
version_link = version_href if version_href else 'Unknown', |
a25d1bf758e6
moar pimping of the error page... at this point, error messages are becoming more of a feature than a bug
Tero Marttila <terom@fixme.fi>
parents:
136
diff
changeset
|
174 |
exception = truncate(exception_str, 512), |
a25d1bf758e6
moar pimping of the error page... at this point, error messages are becoming more of a feature than a bug
Tero Marttila <terom@fixme.fi>
parents:
136
diff
changeset
|
175 |
traceback = cgi.escape(''.join(' ' + line for line in traceback_lines)), |
a25d1bf758e6
moar pimping of the error page... at this point, error messages are becoming more of a feature than a bug
Tero Marttila <terom@fixme.fi>
parents:
136
diff
changeset
|
176 |
trac_query = trac_query, |
a25d1bf758e6
moar pimping of the error page... at this point, error messages are becoming more of a feature than a bug
Tero Marttila <terom@fixme.fi>
parents:
136
diff
changeset
|
177 |
trac_query_url = trac_query_url, |
a25d1bf758e6
moar pimping of the error page... at this point, error messages are becoming more of a feature than a bug
Tero Marttila <terom@fixme.fi>
parents:
136
diff
changeset
|
178 |
trac_query_version = trac_query_version, |
a25d1bf758e6
moar pimping of the error page... at this point, error messages are becoming more of a feature than a bug
Tero Marttila <terom@fixme.fi>
parents:
136
diff
changeset
|
179 |
trac_query_err = trac_query_err, |
135
19ff083c2870
pimp mah error messages, it has a full link to the Trac with pre-filled title, traceback, url, hg revision fields
Tero Marttila <terom@fixme.fi>
parents:
134
diff
changeset
|
180 |
submit_url = submit_url, |
136
c69a176b3620
better string truncation for error messages
Tero Marttila <terom@fixme.fi>
parents:
135
diff
changeset
|
181 |
submit_url_short = truncate(submit_url, 120) |
134
fbccc1648d79
improved error handling for CGI/FastCGI
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
182 |
)).encode('utf-8')) |
fbccc1648d79
improved error handling for CGI/FastCGI
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
183 |