Mercurial > piecrust2
comparison piecrust/serving/server.py @ 523:b22e69ff54f4
serve: Don't show the same error message twice.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Tue, 28 Jul 2015 21:24:10 -0700 |
parents | bab91fcef741 |
children | f2b875ecc940 |
comparison
equal
deleted
inserted
replaced
522:094bdf2f7c4c | 523:b22e69ff54f4 |
---|---|
165 raise | 165 raise |
166 except Exception as ex: | 166 except Exception as ex: |
167 if app.debug: | 167 if app.debug: |
168 logger.exception(ex) | 168 logger.exception(ex) |
169 raise | 169 raise |
170 msg = str(ex) | 170 logger.error(str(ex)) |
171 logger.error(msg) | 171 msg = "There was an error trying to serve: %s" % request.path |
172 raise InternalServerError(msg) from ex | 172 raise InternalServerError(msg) from ex |
173 | 173 |
174 def _try_special_request(self, environ, request): | 174 def _try_special_request(self, environ, request): |
175 static_mount = '/__piecrust_static/' | 175 static_mount = '/__piecrust_static/' |
176 if request.path.startswith(static_mount): | 176 if request.path.startswith(static_mount): |
310 encoding='utf8') as gzip_file: | 310 encoding='utf8') as gzip_file: |
311 gzip_file.write(rp_content) | 311 gzip_file.write(rp_content) |
312 rp_content = gzip_buffer.getvalue() | 312 rp_content = gzip_buffer.getvalue() |
313 response.content_encoding = 'gzip' | 313 response.content_encoding = 'gzip' |
314 except Exception: | 314 except Exception: |
315 logger.exception("Error compressing response, " | 315 logger.error("Error compressing response, " |
316 "falling back to uncompressed.") | 316 "falling back to uncompressed.") |
317 response.set_data(rp_content) | 317 response.set_data(rp_content) |
318 | 318 |
319 return response | 319 return response |
320 | 320 |
321 def _try_render_page(self, app, route, route_metadata, page_num, req_path): | 321 def _try_render_page(self, app, route, route_metadata, page_num, req_path): |