mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-02-03 05:04:31 +03:00
Reuse exception_handler variable throughout
This commit is contained in:
parent
fd003fcefa
commit
89e9fc98d6
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue
Block a user