-
Notifications
You must be signed in to change notification settings - Fork 103
Fix invalid session bad error description #2181
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -103,12 +103,22 @@ def get_error_description(self, error_code): | |
| except errors.Error: | ||
| pass | ||
|
|
||
| try: | ||
| ''' | ||
| It is possible that the session is valid but the returned_error_code unequal to error_code | ||
| ''' | ||
| error_string = self.error_message(error_code) | ||
| return error_string | ||
| except errors.Error: | ||
| pass | ||
|
Comment on lines
+110
to
+113
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
If this happens, then something likely went wrong retrieving the error message. I'm not sure calling |
||
|
|
||
| try: | ||
| ''' | ||
| It is expected for get_error to raise when the session is invalid | ||
| (IVI spec requires GetError to fail). | ||
| Use error_message instead. It doesn't require a session. | ||
| ''' | ||
| self.set_session_handle() | ||
| error_string = self.error_message(error_code) | ||
|
Comment on lines
+121
to
122
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did you add the other
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My current approach is wrong because it reset valid session. Adding error_message call will not help to protect against it because it is unable to know error_message throw exception because of invalid session or any other internal error. Maybe I should compare its error code directly with the invalid error session code? |
||
| return error_string | ||
| except errors.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.
FYI, it's weird that these are multi-line string literals instead of comments. They are not in a position where they will be interpreted as docstrings.
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.
Yeah, that struck me as odd, too.
Apparently the Python interpreter will evaluate it as a string and then discard it?
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.
Yes, it will.
BTW it's legal to write a docstring inside an init method, e.g. https://www.sphinx-doc.org/en/master/usage/extensions/example_google.html
But that's not what's being done here.