Show More
@@ -168,7 +168,7 b' def webob_to_pyramid_http_response(webob' | |||
|
168 | 168 | return pyramid_response |
|
169 | 169 | |
|
170 | 170 | |
|
171 | def error_handler(exc, request): | |
|
171 | def error_handler(exception, request): | |
|
172 | 172 | # TODO: dan: replace the old pylons error controller with this |
|
173 | 173 | from rhodecode.model.settings import SettingsModel |
|
174 | 174 | from rhodecode.lib.utils2 import AttributeDict |
@@ -179,9 +179,14 b' def error_handler(exc, request):' | |||
|
179 | 179 | log.exception('failed to fetch settings') |
|
180 | 180 | rc_config = {} |
|
181 | 181 | |
|
182 | base_response = HTTPInternalServerError() | |
|
183 | # prefer original exception for the response since it may have headers set | |
|
184 | if isinstance(exception, HTTPError): | |
|
185 | base_response = exception | |
|
186 | ||
|
182 | 187 | c = AttributeDict() |
|
183 |
c.error_message = |
|
|
184 |
c.error_explanation = |
|
|
188 | c.error_message = base_response.status | |
|
189 | c.error_explanation = base_response.explanation or str(base_response) | |
|
185 | 190 | c.visual = AttributeDict() |
|
186 | 191 | |
|
187 | 192 | c.visual.rhodecode_support_url = ( |
@@ -189,15 +194,10 b' def error_handler(exc, request):' | |||
|
189 | 194 | request.route_url('rhodecode_support') |
|
190 | 195 | ) |
|
191 | 196 | c.redirect_time = 0 |
|
192 | c.rhodecode_name = rc_config.get('rhodecode_title') | |
|
197 | c.rhodecode_name = rc_config.get('rhodecode_title', '') | |
|
193 | 198 | if not c.rhodecode_name: |
|
194 | 199 | c.rhodecode_name = 'Rhodecode' |
|
195 | 200 | |
|
196 | base_response = HTTPInternalServerError() | |
|
197 | # prefer original exception for the response since it may have headers set | |
|
198 | if isinstance(exc, HTTPError): | |
|
199 | base_response = exc | |
|
200 | ||
|
201 | 201 | response = render_to_response( |
|
202 | 202 | '/errors/error_document.html', {'c': c}, request=request, |
|
203 | 203 | response=base_response) |
@@ -208,6 +208,9 b' def error_handler(exc, request):' | |||
|
208 | 208 | def includeme(config): |
|
209 | 209 | settings = config.registry.settings |
|
210 | 210 | |
|
211 | if asbool(settings.get('appenlight', 'false')): | |
|
212 | config.include('appenlight_client.ext.pyramid_tween') | |
|
213 | ||
|
211 | 214 | # Includes which are required. The application would fail without them. |
|
212 | 215 | config.include('pyramid_mako') |
|
213 | 216 | config.include('pyramid_beaker') |
@@ -247,6 +250,7 b' def includeme(config):' | |||
|
247 | 250 | if not vcs_server_enabled: |
|
248 | 251 | pylons_app_as_view = DisableVCSPagesWrapper(pylons_app_as_view) |
|
249 | 252 | |
|
253 | ||
|
250 | 254 | def pylons_app_with_error_handler(context, request): |
|
251 | 255 | """ |
|
252 | 256 | Handle exceptions from rc pylons app: |
@@ -273,7 +277,14 b' def includeme(config):' | |||
|
273 | 277 | # how to handle a request. |
|
274 | 278 | config.add_notfound_view(pylons_app_with_error_handler) |
|
275 | 279 | |
|
276 | config.add_view(error_handler, context=HTTPError) # exceptions in rc pyramid | |
|
280 | if settings.get('debugtoolbar.enabled', False): | |
|
281 | # if toolbar, then only http type exceptions get caught and rendered | |
|
282 | ExcClass = HTTPError | |
|
283 | else: | |
|
284 | # if no toolbar, then any exception gets caught and rendered | |
|
285 | ExcClass = Exception | |
|
286 | config.add_view(error_handler, context=ExcClass) | |
|
287 | ||
|
277 | 288 | |
|
278 | 289 | def includeme_last(config): |
|
279 | 290 | """ |
@@ -314,6 +325,10 b' def wrap_app_in_wsgi_middlewares(pyramid' | |||
|
314 | 325 | pyramid_app = RoutesMiddleware( |
|
315 | 326 | pyramid_app, config.registry._pylons_compat_config['routes.map']) |
|
316 | 327 | |
|
328 | if asbool(settings.get('appenlight', 'false')): | |
|
329 | pyramid_app, _ = wrap_in_appenlight_if_enabled( | |
|
330 | pyramid_app, config.registry._pylons_compat_config) | |
|
331 | ||
|
317 | 332 | # TODO: johbo: Don't really see why we enable the gzip middleware when |
|
318 | 333 | # serving static files, might be something that should have its own setting |
|
319 | 334 | # as well? |
General Comments 0
You need to be logged in to leave comments.
Login now