Skip to content

Conversation

@tim-mccurrach
Copy link
Contributor

@tim-mccurrach tim-mccurrach commented Nov 19, 2020

More helpful errors in logs / terminal

Currently the default error_handler returns a Response with error details in the response body. Django logs status_code and the url. For ValidationErrors and ParserErrors or any other 400 error this is just "Bad Request", which isn't particularly helpful. There are many other errors where a little extra info beyond the status_code is incredibly helpful.

Django's HttpResponseBase has a reason_phrase property that can be used to provide more detail.

  • In cases where the exception has a detail that is either a string, or a an array of length 1 this detail can be added
  • In more complicated cases a message such as "See response body for full details" can be appended, to point people in the right direction.

Closes #7645

Improve reason_phrase for error details that are length 1 lists.

Use reason_phrase property rather than non-public attribute

Replace f-strings with format for py35 compatability

Replace missed f-string with format
@tim-mccurrach tim-mccurrach force-pushed the add-more-useful-error-messages branch from 4e73018 to 3e1fca1 Compare December 2, 2020 19:47
@JocelynDelalande
Copy link
Contributor

Django's HttpResponseBase has a reason_phrase property that can be used to provide more detail.

The « reason » seems beyond logging purpose as it is returned back to http client.

@stale
Copy link

stale bot commented Apr 30, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Apr 30, 2022
@lovelydinosaur
Copy link
Contributor

I don't think we'd want to do this. It's not a typical usage of HTTP reason phrases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

More helpful errors in logs / terminal

3 participants