-
Notifications
You must be signed in to change notification settings - Fork 14
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
chore: Improve errors.py #100
Conversation
This will fix an error we have in our usage of this error.
@@ -113,7 +112,7 @@ def __init__(self, additional_info=None): | |||
http.client.responses.get(http.client.NOT_FOUND), | |||
) | |||
if additional_info: | |||
error_message += " : " + additional_info |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change (removing a space from the message to make it consistent with the other messages) requires a small test fix in our downstream service.
@@ -170,7 +173,7 @@ def __init__(self, additional_info=None): | |||
class ClientErrorResponseWrapper(ClientError): | |||
def __init__(self, response): | |||
error_code = response.status_code | |||
error_message = response.content | |||
error_message = response.content.decode() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
error_message
is bytestring unless we do this. Maybe this wasn't an issue until Python 3?
@@ -84,7 +84,7 @@ | |||
# | |||
# This is also used if you do content translation via gettext catalogs. | |||
# Usually you set "language" from the command line for these cases. | |||
language = None | |||
language = 'en' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Letting language
be None
causes an error with a new version of Sphinx.
error_code, error_message = LOGGED_SERVER_ERROR | ||
error_message = error_message.format(uuid.uuid4()) | ||
if additional_info: | ||
error_message += f": {additional_info}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe that this error_message
is returned directly to the client. Should we make it so that the additional_info
only appears in logs, and the client only gets the opaque error UUID?
Requires running tests with logging on
@@ -21,8 +21,6 @@ | |||
|
|||
ROOT_URLCONF = "tests.urls" | |||
|
|||
TEST_RUNNER = "tests.testutils.NoLoggingTestRunner" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did this so I could test the logging on the ServerError
Let ServerError take an
additional_info
argumentUse f-strings throughout errors.py
Use enum value rather than bare int for an error code
Add some unit tests for errors.py to bump up coverage
Bump coverage check to 91%
Fix a Sphinx configuration error that appears with a new version of Sphinx (to get the PR checks to pass)
Update CHANGELOG.md
Update README.md (as needed)
New dependencies were added to
requirements.txt
orrequirements-dev.txt
pip install
succeeds with a clean virtualenvThere are new or modified tests that cover changes
Test coverage is maintained or expanded