Reuse exception_handler variable throughout

This commit is contained in:
José Padilla 2014-12-14 15:20:44 -04:00
parent fd003fcefa
commit 89e9fc98d6

View File

@ -371,16 +371,18 @@ class APIView(View):
else: else:
exc.status_code = status.HTTP_403_FORBIDDEN exc.status_code = status.HTTP_403_FORBIDDEN
if len(inspect.getargspec(self.settings.EXCEPTION_HANDLER).args) == 1: exception_handler = self.settings.EXCEPTION_HANDLER
if len(inspect.getargspec(exception_handler).args) == 1:
warnings.warn( warnings.warn(
'The `exception_handler(exc)` call signature is deprecated. ' 'The `exception_handler(exc)` call signature is deprecated. '
'Use `exception_handler(exc, context) instead.', 'Use `exception_handler(exc, context) instead.',
PendingDeprecationWarning PendingDeprecationWarning
) )
response = self.settings.EXCEPTION_HANDLER(exc) response = exception_handler(exc)
else: else:
context = self.get_renderer_context() context = self.get_renderer_context()
response = self.settings.EXCEPTION_HANDLER(exc, context) response = exception_handler(exc, context)
if response is None: if response is None:
raise raise