This repository has been archived by the owner on Feb 22, 2023. It is now read-only.
Remove get_api_exception
and replace with built in DRF exceptions
#843
Labels
💻 aspect: code
Concerns the software code in the repository
🧰 goal: internal improvement
Improvement that benefits maintainers, not users
good first issue
New-contributor friendly
help wanted
Open to participation from the community
🟩 priority: low
Low priority and doesn't need to be rushed
Description
The bespoke
get_api_exception
function recreates built in DRF functionality and makes searching for particular exceptions more difficult. Instead of searching forraise NotFound
orraise <built-in-DRF-exception>
, the typical way to find code that explicitly raises exceptions, you'd have to know about theget_api_exception
function and search for usages with the specific HTTP status code (which has to be hand written by the user each time, meaning they have to remember what the status code is).It also obscures stack traces because all errors created by
get_api_exception
have the same name (only solvable by further meta programming using thetype
constructor instead of a closed class): https://sentry.io/share/issue/abf49297eb2749e889eff15e4d37e151/In short: we can eliminate code by removing this, be more in line with default DRF functionality and the community.
get_api_exception
function with the appropriate built-in DRF exception fromrest_framework.exceptions
. For any that are following thetry: queryset.get(); except Model.DoesNotExist: ...
pattern, replace it withget_object_or_404
.get_api_exception
functionThe text was updated successfully, but these errors were encountered: