Skip to content
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

CosmosException: Fixes substatuscode to get the correct value instead of 0 when it is not in the enum. #2110

Merged
merged 5 commits into from
Jan 12, 2021

Conversation

j82w
Copy link
Contributor

@j82w j82w commented Jan 7, 2021

Pull Request Template

Description

The document client exception that is thrown internally will return default value if the SubStatusCode is not defined in the enum. This changes the logic to parse and use the int from the headers so the exception always shows the correct value. This allows the SDK to properly handle unexpected or newer substatuscodes that it is not aware of.

Type of change

Please delete options that are not relevant.

  • [] Bug fix (non-breaking change which fixes an issue)
  • [] New feature (non-breaking change which adds functionality)
  • [] Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • [] This change requires a documentation update

Closing issues

To automatically close an issue: closes #IssueNumber

@j82w j82w added the bug Something isn't working label Jan 7, 2021
@j82w j82w self-assigned this Jan 7, 2021
@@ -108,7 +93,7 @@ internal static class CosmosExceptionFactory

return CosmosExceptionFactory.Create(
responseMessage.StatusCode,
(int)responseMessage.Headers.SubStatusCode,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On a happy path (not exception), the ResponseMessage.Headers.SubStatusCode also has the same issue, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct, but that is a internal field. If you are programming against the enum it makes since that it would use the default if you gave it value that wasn't supported by the enum.

@j82w j82w changed the title CosmosException: Fixes substatuscode parsing to handle new codes instead of using default value CosmosException: Fixes substatuscode to get the correct value instead of 0 when it is not in the enum. Jan 12, 2021
@j82w j82w merged commit 1e9c566 into master Jan 12, 2021
@j82w j82w deleted the users/jawilley/bug/substatuscode branch January 12, 2021 17:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants