-
Notifications
You must be signed in to change notification settings - Fork 74
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
Improve ApiError message formatting; add response
field to ApiError and UnexpectedResponseError
#467
Improve ApiError message formatting; add response
field to ApiError and UnexpectedResponseError
#467
Conversation
8753b1a
to
e6e69a9
Compare
if json and "errors" in json and isinstance(json["errors"], list): | ||
self.errors = [e["reason"] for e in json["errors"]] | ||
|
||
@classmethod | ||
def from_response( |
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 originally wanted to implement the formatting logic using a __str__
override but instead opted for this implementation to reduce the chances of a breaking change.
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.
Everything is passing locally!
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.
LGTM, tests passed locally
📝 Description
This pull request improves the ApiError message formatting logic to include the method and path of the failed request. This is done through a new
ApiError.from_request(...)
class method, which as a bonus simplifies and unifies API error construction across the project.✔️ How to Test
The following test steps assume you have pulled down this PR locally and run
make install
.Unit Testing
Integration Testing
Manual Testing