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

DRF exception handling #119

Closed
jayvdb opened this issue Jul 10, 2020 · 4 comments
Closed

DRF exception handling #119

jayvdb opened this issue Jul 10, 2020 · 4 comments

Comments

@jayvdb
Copy link
Contributor

jayvdb commented Jul 10, 2020

When the value of setting REST_FRAMEWORK.EXCEPTION_HANDLER is the default, the responses for each end-point should include response types for the exceptions it handles.

https://github.com/encode/django-rest-framework/blob/82c2b5c3e75debe047eebd8a17b50c1e17594663/docs/api-guide/exceptions.md

This includes many of the 400s, notably doesnt include 500s.

Also it would be lovely if the extension framework here was used so that custom values of REST_FRAMEWORK.EXCEPTION_HANDLER loaded any extension targetting that class, so that e.g. drf-problems can be supported, but there are many others commonly used like drf-friendly-errors.

@jayvdb jayvdb changed the title Error handling DRF exception handling Jul 10, 2020
@jayvdb
Copy link
Contributor Author

jayvdb commented Jul 10, 2020

https://github.com/ivlevdenis/drf_pretty_exception_handler#features has a nice summary of the very varied response payloads that default DRF emits.

@jayvdb
Copy link
Contributor Author

jayvdb commented Jul 11, 2020

A possible (temporary?) solution would to create a post-processing hook to append the following to every path.

      responses:
        ...
        default:
          insert_ref_here_to_a_component_broadly_describing_of_all_drf_possible_responses

@tfranzel
Copy link
Owner

related to #101 and #116

@jayvdb
Copy link
Contributor Author

jayvdb commented Jul 11, 2020

Closing in favour of #101 , with a comment there for some considerations.

@jayvdb jayvdb closed this as completed Jul 11, 2020
wmfgerrit pushed a commit to wikimedia/wikimedia-toolhub that referenced this issue Feb 3, 2021
Document the general error message structure in our generated OpenAPI
schema. This uses a technique suggested in
<tfranzel/drf-spectacular#119> to augment the
schema. In the future an implementation for
<tfranzel/drf-spectacular#101> may make this
code obsolete.

Bug: T268774
Change-Id: I77c3afffc90213d44f394e17314b28938136a325
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants