Skip to content

Add per-view custom exception handler support #4753

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 15, 2016
Merged

Add per-view custom exception handler support #4753

merged 1 commit into from
Dec 15, 2016

Conversation

ediskandarov
Copy link
Contributor

Description

It is possible to set custom exception handler using the EXCEPTION_HANDLER setting key.
But it's hard to override exception handler on per-view basis.
To do this it's necessary to override rest_framework.view.APIView.handle_exception method.
What is unreasonably complex.

This PR adds ability to easily override custom exception handler on view using rest_framework.view.APIView.get_exception_handler method.

@xordoquy
Copy link
Collaborator

What would the use case be ?
Do we really need a per view custom exception handler ?

@ediskandarov
Copy link
Contributor Author

In my case I want to use custom exception handler for new API not to break compatibility with legacy code.

@tomchristie
Copy link
Member

I think we'd be okay with this, yup. It'd need adding to the documention in this section... http://www.django-rest-framework.org/api-guide/views/#api-policy-instantiation-methods

@ediskandarov
Copy link
Contributor Author

@tomchristie , updated

@tomchristie tomchristie added this to the 3.5.4 Release milestone Dec 15, 2016
@tomchristie tomchristie merged commit ebe174c into encode:master Dec 15, 2016
@tomchristie
Copy link
Member

Thanks!

@ediskandarov ediskandarov deleted the per-view-exception-handler branch December 15, 2016 12:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants