#34430 closed Uncategorized (invalid)

Custom exception handler not called

Reported by: frontierconnect Owned by: nobody
Component: Generic views Version: 4.1
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

coded my own method custom_exception_handler for exception handling but for authentication exception this callback is not called

I configured in my settings the callback under:

REST_FRAMEWORK = {'EXCEPTION_HANDLER' : 'myapp.api.response.custom_exception_handler',}

Simple performing a api call without token (that requires auth), it is raised NotAuthenticated exception, that is returning on Response

{"detail":"Authentication credentials were not provided."}

My view class is inherited from rest_framework.viewsets.GenericViewSet that inherits APIView

I noticed that the exception handler callback is managed in APIView

exception_handler = self.get_exception_handler()

that returns settings.EXCEPTION_HANDLER that pointing to default rest_framework exception handler.

Seems that REST_FRAMEWORK configuration is not taken into account.


Change History (1)

comment:1 by Mariusz Felisiak, 21 months ago

Resolution: invalid
Status: newclosed

There is no such setting in Django as REST_FRAMEWORK.

Please don't use Trac as a support channel. Closing per TicketClosingReasons/UseSupportChannels.

Note: See TracTickets for help on using tickets.
Back to Top