Repository navigation
feat: keep SAIC’s return code and message on every error (#54) - #55
Merged
Merged
Conversation
…-API#54) SaicApiException now keeps the return code and SAIC's message as separate attributes (return_code, saic_message) and offers checks for the common cases (is_vehicle_unreachable, is_request_rejected, is_vehicle_not_locked, is_logged_out, is_unexpected_failure), with the known codes in SaicReturnCode. str(e) is unchanged, so code that reads the text keeps working.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #54. Part of #26.
SaicApiExceptionnow keeps SAIC's reply as separate values, so callers don't have to parsestr(e)to find out why a call failed.Changes
return_codeandsaic_message: new attributes onSaicApiExceptionand all its subclasses.return_codeis SAIC's numeric code (orNone);saic_messageis the message on its own.SaicReturnCode: a new enum of the codes with a known meaning:SUCCESSVEHICLE_UNREACHABLESERVICE_UNAVAILABLEREQUEST_REJECTEDUNAUTHORIZED/FORBIDDENUNEXPECTED_FAILURECodes not listed still come through unchanged in
return_code.is_vehicle_unreachable,is_request_rejected,is_vehicle_not_locked(code 8 with "not locked" in the message, as opposed to the remote command limit, which is also code 8),is_logged_out(always true onSaicLogoutException) andis_unexpected_failure.super().__init__(), soe.argsis set and they pickle cleanly.str(e)is unchanged ("return code: <code>, message: <message>", or just the message), includingSaicApiRetryException'sevent_idsuffix. Existing code that reads the text keeps working.Tests
tests/test_exceptions.pycovers:argsand pickling;Notes