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
feat: error message return from api #235
Merged
Merged
Changes from 1 commit
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
d18c3b1
feat(storage): error message retyrn from api
HemangChothani 1820f55
Merge branch 'master' into storage_issue_224
tseaver 970ece9
Merge branch 'master' of https://github.com/googleapis/python-storage…
HemangChothani ae8de9d
Merge branch 'storage_issue_224' of https://github.com/q-logic/python…
HemangChothani 57a1358
feat: add comment for clarification
HemangChothani dc9f4ff
Merge branch 'master' of https://github.com/googleapis/python-storage…
HemangChothani aa332f6
Merge branch 'master' of https://github.com/googleapis/python-storage…
HemangChothani 07c2478
Merge branch 'master' of https://github.com/googleapis/python-storage…
HemangChothani 39f00df
Merge branch 'master' into storage_issue_224
frankyn 562abfd
fix: remove unknown error
HemangChothani File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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'd prefer not to add the prefix here. @frankyn WDYT?
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.
Could you clarify the difference between response.text and error (add comments I suspect others will ask this question when reviewing the code in the future).
I also think repsonse.text could be added to the line below when constructing the
message
value instead of this conditional.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.
@frankyn I have added condition here to match the method which is responsible for other http responses and errors declared in
pytho-api-core.exceptions.from_http_response
you can find here https://github.com/googleapis/python-api-core/blob/622931721ce34839d630aa1e974c7d8f47b5d25e/google/api_core/exceptions.py#L390-L411response.text:
gives the actual reason of errorstr(error):
gives ('Request failed with status code', 404(Error Code), 'Expected one of', <HTTPStatus.OK: 200>, <HTTPStatus.PARTIAL_CONTENT: 206>)I think here we can remove
str(error)
as it's not meaning full for the users, also not included in other http methods from python-api-core as mention above.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.
@frankyn I think it's necessary to add actual reason in error message, Ex: in the #249 issue user share a stack trace of error but it's hard to debug as actual reason isn't there in message.
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 think I need to pull in @andrewsg on this one when he has a moment.
Andrew do you have guidance on raising the actual error that occurred in this case?
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.
If I understand correctly, the problem here is the same as I've observed elsewhere where the API responds with human-readable text which is not converted into a specific error message by our client library. Prepending this human-readable text does make sense though I'm neutral on whether we should include the "unknown error" prepending in the
else
case.We should make sure that the traceback still includes the original function call that caused the error.
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.
Thanks @andrewsg.
I don't see the value of
unknown error:
and could be confusing otherwise. Please only preppendresponse.text
when it's available. Removeunknown error:
.