Skip to content
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

Add per-view custom exception handler support #4753

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

emcpow2
Copy link
Contributor

@emcpow2 emcpow2 commented Dec 14, 2016

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

xordoquy commented Dec 15, 2016

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

@emcpow2
Copy link
Contributor Author

emcpow2 commented Dec 15, 2016

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

@tomchristie
Copy link
Member

tomchristie commented Dec 15, 2016

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

@emcpow2
Copy link
Contributor Author

emcpow2 commented Dec 15, 2016

@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
3 checks passed
@tomchristie
Copy link
Member

tomchristie commented Dec 15, 2016

Thanks!

@emcpow2 emcpow2 deleted the per-view-exception-handler branch Dec 15, 2016
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.

None yet

3 participants