Merge lp:~andrea.corbellini/beeseek/error-page into lp:beeseek/1.0
- error-page
- Merge into 1.0
Proposed by
Andrea Corbellini
Status: | Merged |
---|---|
Merged at revision: | not available |
Proposed branch: | lp:~andrea.corbellini/beeseek/error-page |
Merge into: | lp:beeseek/1.0 |
Diff against target: | 340 lines |
To merge this branch: | bzr merge lp:~andrea.corbellini/beeseek/error-page |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Andrea Colangelo | ui | Approve | |
Jacopo Moretto (community) | Approve | ||
Review via email: mp+14786@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
Revision history for this message
Andrea Corbellini (andrea.corbellini) wrote : | # |
Revision history for this message
Jacopo Moretto (jak-o) : | # |
review:
Approve
Revision history for this message
Jacopo Moretto (jak-o) : | # |
review:
Approve
Revision history for this message
Andrea Colangelo (warp10) : | # |
review:
Approve
(ui)
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'beeseek/app/log.py' |
2 | --- beeseek/app/log.py 2009-10-21 15:39:48 +0000 |
3 | +++ beeseek/app/log.py 2009-11-12 13:55:22 +0000 |
4 | @@ -141,7 +141,7 @@ |
5 | for name in dir(self_obj): |
6 | try: |
7 | value = getattr(self_obj, name) |
8 | - except StandardError: |
9 | + except Exception: |
10 | # XXX We can use somewhat better. |
11 | value = NotImplementedError |
12 | f_self[name] = value |
13 | |
14 | === modified file 'beeseek/template/css.py' |
15 | --- beeseek/template/css.py 2009-09-15 13:40:21 +0000 |
16 | +++ beeseek/template/css.py 2009-11-12 13:55:22 +0000 |
17 | @@ -20,3 +20,5 @@ |
18 | #pylint: disable-msg=C0103 |
19 | style = Template('css/style.css', dont_parse=True, |
20 | tags={'content-type': 'text/css'}) |
21 | +style_error = Template('css/style-error.css', dont_parse=True, |
22 | + tags={'content-type': 'text/css'}) |
23 | |
24 | === modified file 'beeseek/template/html.py' |
25 | --- beeseek/template/html.py 2009-10-24 12:25:08 +0000 |
26 | +++ beeseek/template/html.py 2009-11-12 13:55:22 +0000 |
27 | @@ -21,3 +21,4 @@ |
28 | start_page = Template('html/home.html') |
29 | search_page = Template('html/search.html') |
30 | configuration_page = Template('html/configuration.html') |
31 | +error_page = Template('html/error.html') |
32 | |
33 | === modified file 'beeseek/template/images.py' |
34 | --- beeseek/template/images.py 2009-09-15 13:40:21 +0000 |
35 | +++ beeseek/template/images.py 2009-11-12 13:55:22 +0000 |
36 | @@ -20,3 +20,5 @@ |
37 | #pylint: disable-msg=C0103 |
38 | logo = Template('images/logo.png', dont_parse=True, |
39 | tags={'content-type': 'image/png'}) |
40 | +bars = Template('images/bars.png', dont_parse=True, |
41 | + tags={'content-type': 'image/png'}) |
42 | |
43 | === modified file 'beeseek/ui/__init__.py' |
44 | --- beeseek/ui/__init__.py 2009-10-24 12:54:21 +0000 |
45 | +++ beeseek/ui/__init__.py 2009-11-12 13:55:22 +0000 |
46 | @@ -33,6 +33,10 @@ |
47 | template = css.style |
48 | elif page == '/beeseek:logo.png': |
49 | template = images.logo |
50 | + elif page == '/beeseek:style-error.css': |
51 | + template = css.style_error |
52 | + elif page == '/beeseek:bars.png': |
53 | + template = images.bars |
54 | else: |
55 | return False |
56 | data = template.format() |
57 | |
58 | === modified file 'beeseek/web/servers/baseserver.py' |
59 | --- beeseek/web/servers/baseserver.py 2009-10-21 17:05:04 +0000 |
60 | +++ beeseek/web/servers/baseserver.py 2009-11-12 13:55:22 +0000 |
61 | @@ -191,9 +191,9 @@ |
62 | except StopServing: |
63 | self.stop_serving() |
64 | return |
65 | - except StandardError: |
66 | + except Exception, exc: |
67 | try: |
68 | - self.handle_error(client, requestdata) |
69 | + self.handle_error(client, requestdata, exc) |
70 | except StopProcessing, exc: |
71 | close = exc.close |
72 | except StopServing: |
73 | @@ -220,7 +220,8 @@ |
74 | client.close() |
75 | |
76 | @Method.with_default |
77 | - def handle_error(self, client, requestdata): #pylint: disable-msg=W0613 |
78 | + def handle_error( |
79 | + self, client, requestdata, exc): #pylint: disable-msg=W0613 |
80 | """Called by serve_request() when an exception is raised. |
81 | |
82 | By default, this function raises the exception. |
83 | |
84 | === modified file 'beeseek/web/servers/http.py' |
85 | --- beeseek/web/servers/http.py 2009-10-21 17:02:40 +0000 |
86 | +++ beeseek/web/servers/http.py 2009-11-12 13:55:22 +0000 |
87 | @@ -30,8 +30,9 @@ |
88 | from beeseek.web.protocols.http import ( |
89 | HTTPMethods, HTTPServerApplication, HTTPClientApplication, |
90 | get_host_port_and_page) |
91 | -from beeseek.web.protocols.lowlevel import SSLContext |
92 | +from beeseek.web.protocols.lowlevel import SocketError, SSLContext |
93 | from beeseek.web.servers.baseserver import BaseServer, StopProcessing |
94 | +from beeseek.template.html import error_page |
95 | from beeseek.template.javascript import pac |
96 | |
97 | |
98 | @@ -51,13 +52,11 @@ |
99 | method, page = requestline[:2] |
100 | |
101 | if show_page(client, page): |
102 | - return |
103 | + pass |
104 | elif page in ('/search', '/search/'): |
105 | show_start_page(client, method) |
106 | - return True |
107 | elif page.startswith('/search/'): |
108 | show_results(client, page) |
109 | - return True |
110 | elif page == '/submit-oops' and method == HTTPMethods.POST: |
111 | self._save_oops_report(client, headers) |
112 | else: |
113 | @@ -240,7 +239,17 @@ |
114 | client.end_response() |
115 | client.flush() |
116 | |
117 | - def handle_capacity_limit(self, client): |
118 | - """See `BaseServer`.""" |
119 | - # TODO Show a message and log the error |
120 | - raise NotImplementedError |
121 | + def handle_error(self, client, requestdata, exc): |
122 | + """Show a page describing the error with some useful information.""" |
123 | + if isinstance(exc, SocketError): |
124 | + data = error_page.format( |
125 | + errorname='server-not-found', details=str(exc)) |
126 | + headers = instance.http_response_headers.copy() |
127 | + headers['Content-Length'] = str(len(data)) |
128 | + headers['Content-Type'] = error_page.template_tags['content-type'] |
129 | + client.start_response(404, 'Not found', headers) |
130 | + client.write(data) |
131 | + client.end_response() |
132 | + client.flush() |
133 | + else: |
134 | + raise |
135 | |
136 | === added file 'templates/css/style-error.css' |
137 | --- templates/css/style-error.css 1970-01-01 00:00:00 +0000 |
138 | +++ templates/css/style-error.css 2009-11-12 13:55:22 +0000 |
139 | @@ -0,0 +1,47 @@ |
140 | +body { |
141 | + background-color: #EFEFEF; |
142 | + font-family: sans-serif; |
143 | + font-size: 12pt; |
144 | +} |
145 | + |
146 | +.details { |
147 | + font-size: 9pt; |
148 | +} |
149 | + |
150 | +div#actions { |
151 | + text-align: center; |
152 | +} |
153 | + |
154 | +div#details { |
155 | + /* By default details are hidden. */ |
156 | + display: none; |
157 | +} |
158 | + |
159 | +div#warning { |
160 | + border: 2px solid #FAC232; |
161 | + background: #FFFFFF url(/beeseek:bars.png) repeat-x; |
162 | + left: 20%; |
163 | + padding: 0.5em 0 0.5em 1.2em; |
164 | + position: absolute; |
165 | + top: 10%; |
166 | + width: 60%; |
167 | + |
168 | + /* Display a round border. */ |
169 | + /* TODO The following properties are not W3 standard (and therefore not |
170 | + * TODO supported on all browsers). It may be better to use images. */ |
171 | + -moz-border-radius: 30px; |
172 | + -o-border-radius: 30px; |
173 | + -webkit-border-radius: 30px; |
174 | + -ktml-border-radius: 30px; |
175 | +} |
176 | + |
177 | +div#warning h1 { |
178 | + color: #EE8A03; |
179 | + font-size: 20pt; |
180 | +} |
181 | + |
182 | +div#warning a { |
183 | + color: #556D7A; |
184 | + text-decoration: none; |
185 | + font-weight: bold; |
186 | +} |
187 | |
188 | === added file 'templates/html/error-messages.xml' |
189 | --- templates/html/error-messages.xml 1970-01-01 00:00:00 +0000 |
190 | +++ templates/html/error-messages.xml 2009-11-12 13:55:22 +0000 |
191 | @@ -0,0 +1,18 @@ |
192 | +<beeseek:template content-type="text/html"> |
193 | + <beeseek:container id="server-not-found"> |
194 | + <beeseek:object id="title">Cannot connect to server</beeseek:object> |
195 | + <beeseek:object id="message">Unable to establish a connection with the server.</beeseek:object> |
196 | + <beeseek:object id="rationale"> |
197 | + <p>Possible causes of this issue:</p> |
198 | + <ul> |
199 | + <li>The site could be temporarily unavailable or too busy. Try again |
200 | + in a few moments.</li> |
201 | + <li>If you are unable to load any pages, check your computer's network |
202 | + connection.</li> |
203 | + <li>If your computer or network is protected by a firewall or proxy, |
204 | + make sure that <beeseek:insert type="variable" name="instance.appname" /> |
205 | + is permitted to access the Net.</li> |
206 | + </ul> |
207 | + </beeseek:object> |
208 | + </beeseek:container> |
209 | +</beeseek:template> |
210 | |
211 | === modified file 'templates/html/error.html' |
212 | --- templates/html/error.html 2008-08-27 13:51:34 +0000 |
213 | +++ templates/html/error.html 2009-11-12 13:55:22 +0000 |
214 | @@ -1,87 +1,44 @@ |
215 | -<?xml version="1.0" encoding="UTF-8"?> |
216 | -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
217 | -<html xmlns="http://www.w3.org/1999/xhtml"> |
218 | +<beeseek:template content-type="text/html"><?xml version="1.0" encoding="UTF-8"?> |
219 | +<html> |
220 | <head> |
221 | - <title> |
222 | - Error |
223 | - </title> |
224 | - <meta http-equiv="Content-type" content='text/html; charset="UTF-8"' /> |
225 | - <style type="text/css"> |
226 | - body{ |
227 | - margin: 0; |
228 | - padding: 0; |
229 | - background: #fff; |
230 | - font-family: "Bitstream Vera Sans", "Trebuchet MS", "Trebuchet", "Verdana", "Arial", "Sans-serif"; |
231 | - font-size: 9pt; |
232 | - color: #121212; |
233 | - } |
234 | - |
235 | - h3 { |
236 | - font-size: 140%; |
237 | - } |
238 | - |
239 | - #logo h1{ |
240 | - position: relative; |
241 | - width: 250px; |
242 | - left: 50%; |
243 | - margin: 0 0 0 -125px; |
244 | - padding: 10px 0 0 0; |
245 | - color: #000; |
246 | - font-size: 20pt; |
247 | - } |
248 | - |
249 | - #howto{ |
250 | - background: #e6eed3; |
251 | - border: #ffc90f 1px solid; |
252 | - padding: 10px; |
253 | - margin: 20px; |
254 | - font-weight: bold; |
255 | - } |
256 | - |
257 | - #howto a{ |
258 | - color: #556d7a; |
259 | - } |
260 | - |
261 | - #content{ |
262 | - border: #ffc90f 1px solid; |
263 | - margin: 0 20px; |
264 | - padding: 0px 20px 0 20px; |
265 | - } |
266 | - |
267 | - #traceback{ |
268 | - background: #f8f8f8; |
269 | - border: #cccccc 1px solid; |
270 | - margin: 0 0 10px 0; |
271 | - padding: 10px; |
272 | - font-size: 8pt; |
273 | - } |
274 | - |
275 | - textarea{ |
276 | - background: #f8f8f8; |
277 | - border: none; |
278 | - width:100%; |
279 | - min-height: 300px; |
280 | - } |
281 | - </style> |
282 | + <title><beeseek:insert type="object" file="html/error-messages.xml" id="%(errorname)s.title" /></title> |
283 | + <link rel="stylesheet" type="text/css" media="screen" href="/beeseek:style-error.css" /> |
284 | + <script type="text/javascript"> |
285 | + function toggle_details() { |
286 | + var box_style; |
287 | + var label; |
288 | + |
289 | + box_style = document.getElementById('details').style; |
290 | + label = document.getElementById('details-label'); |
291 | + |
292 | + if (box_style.display == 'block') { |
293 | + label.innerHTML = 'Technical details'; |
294 | + box_style.display = 'none'; |
295 | + } else { |
296 | + label.innerHTML = 'Hide technical details'; |
297 | + box_style.display = 'block'; |
298 | + } |
299 | + } |
300 | + </script> |
301 | </head> |
302 | <body> |
303 | - <div id="header"> |
304 | - <div id="logo"> |
305 | - <h1> |
306 | - Error |
307 | - </h1> |
308 | + <div id="warning"> |
309 | + <h1><beeseek:insert type="object" file="html/error-messages.xml" id="%(errorname)s.title" /></h1> |
310 | + <p><strong><beeseek:insert type="object" file="html/error-messages.xml" id="%(errorname)s.message" /></strong></p> |
311 | + <beeseek:insert type="object" file="html/error-messages.xml" id="%(errorname)s.rationale" /> |
312 | + <div id="actions"> |
313 | + <button id="try-again">Try again</button> |
314 | + <button id="search">Search in the Web</button> |
315 | </div> |
316 | - </div> |
317 | - <div id="howto"> |
318 | - Sorry, an error has occurred. Try to reload this page to solve the problem. If it still occurs, please <a href="https://launchpad.net/honeybee/+filebug">report this bug</a> including the following information. Thanks for your patient! |
319 | - </div> |
320 | - <div id="content"> |
321 | - <h3> |
322 | - Traceback: |
323 | - </h3> |
324 | - <div id="traceback"> |
325 | - <textarea rows="1" cols="1" readonly="readonly"><![CDATA[$traceback]]></textarea> |
326 | + <p class="details"> |
327 | + <a id="details-label" href="#details" onclick="toggle_details()">Technical details</a> |
328 | + </p> |
329 | + <div id="details" class="details"> |
330 | + <pre> |
331 | +<beeseek:insert type="variable" name="details" /> |
332 | + </pre> |
333 | </div> |
334 | </div> |
335 | </body> |
336 | </html> |
337 | +</beeseek:template> |
338 | |
339 | === added file 'templates/images/bars.png' |
340 | Binary files templates/images/bars.png 1970-01-01 00:00:00 +0000 and templates/images/bars.png 2009-11-12 13:55:22 +0000 differ |
This branch adds a web page that is shown to the user when an error in the proxy occurs.
Currently it is only displayed when the host that the user is trying to connect to cannot be found, but in the future it will be used for any error.
How to test this change:
1. Start the server with 'beeseek-server start -t'; something/>)
2. Start the peer with 'beeseek-peer start -t' and set it as your proxy;
3. Visit a URL that doesn't exist (e.g. <http://
You should see a page telling you that the host cannot be found.