- request._cached_node_path = view_kwargs.get('path', '/')
\ No newline at end of file
+ try:
+ request._cached_node_path = view_kwargs['path']
+ except KeyError:
+ pass
+
+ def process_exception(self, request, exception):
+ if settings.DEBUG or not hasattr(request, 'node') or not request.node:
+ return
+
+ if isinstance(exception, Http404):
+ error_view = request.node.attributes.get('Http404', None)
+ else:
+ error_view = request.node.attributes.get('Http500', None)
+
+ if error_view is None or not isinstance(error_view, View):
+ # Should this be duck-typing? Perhaps even no testing?
+ return
+
+ extra_context = {'exception': exception}
+ return error_view.render_to_response(request, extra_context)
\ No newline at end of file