-
-
Notifications
You must be signed in to change notification settings - Fork 7k
Closed
Description
Checklist
- I have verified that that issue exists against the
masterbranch of Django REST framework. - I have searched for similar issues in both open and closed tickets and cannot find a duplicate.
- This is not a usage question.
- This cannot be dealt with as a third party library.
- I have reduced the issue to the simplest possible case.
- I have included a
failingpassing test as a pull request.
Steps to reproduce
Useful information from Exceptions that could helpfully be logged is often not:
class SomeView(APIView):
def get(self,request):
raise ValidationError("Some useful message")
Expected Hoped for behavior
# In the terminal / logs
Bad Request (Some useful message): /some/url/
# Or if the exception details aren't a single string
Bad Request (See response body for details): /some/url/
Actual behavior
# In the terminal / logs
Bad Request: /some/url/
The terminal is probably the first place I look when something isn't working, and the above doesn't leave much of a starting point for investigation. In my case it turned out to just be a ValidationError, but I didn't think of checking the response body (where the error details were returned) until quite a bit of time spent debugging (and not getting anywhere). It would be useful to have slightly more info than just the status code (especially for people new to DRF!).
The logging above actually happens in django, not DRF, however django provides means to customise the message. (see PR)
This will:
- make it easy to distinguish between
ValidationErrors andParserErrors, (which are both 400s) and betweenAuthenticationFailedandNotAuthenticatederrors (which are both 401s). - In cases where the error details are too much to display simply, at least point anyone reading the error in the right direction.
Metadata
Metadata
Assignees
Labels
No labels