From 0d109c90a74bc575efa6d497a6501aef2b837983 Mon Sep 17 00:00:00 2001 From: José Padilla Date: Sat, 13 Dec 2014 18:18:00 -0400 Subject: Add context to exception handler #2236 Same context as renderers which include: the view, args, kwargs, and request. This provides enough contextual information to the exception handlers to handle errors better. In a use case like #1671, a custom handler would allow Sentry to log the request properly.--- rest_framework/views.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'rest_framework') diff --git a/rest_framework/views.py b/rest_framework/views.py index bc870417..07e71393 100644 --- a/rest_framework/views.py +++ b/rest_framework/views.py @@ -46,7 +46,7 @@ def get_view_description(view_cls, html=False): return description -def exception_handler(exc): +def exception_handler(exc, context=None): """ Returns the response that should be used for any given exception. @@ -369,7 +369,8 @@ class APIView(View): else: exc.status_code = status.HTTP_403_FORBIDDEN - response = self.settings.EXCEPTION_HANDLER(exc) + context = self.get_renderer_context() + response = self.settings.EXCEPTION_HANDLER(exc, context) if response is None: raise -- cgit v1.2.3