Add custom exception handling class per APIView #7859
Replies: 4 comments
-
You can simply override the |
Beta Was this translation helpful? Give feedback.
-
@xordoquy That is indeed possible, but then you have to override (and possible copy+paste) the entire method just to change the particular Would you consider having this as a feature if I can come up with a PR? |
Beta Was this translation helpful? Give feedback.
-
Not something we'd support no. The exception handler should be a global case. For more specific cases write the view logic explicitly. |
Beta Was this translation helpful? Give feedback.
-
In recent versions, you can override django-rest-framework/rest_framework/views.py Lines 294 to 298 in b25ac6c |
Beta Was this translation helpful? Give feedback.
-
Would it be possible to add custom exception handling per each APIView? It could just follow the same style[1] as all the other classes and just fallback to the original behavior if not set.
[1] https://github.com/tomchristie/django-rest-framework/blob/master/rest_framework/views.py#L101
Beta Was this translation helpful? Give feedback.
All reactions