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

Avoid throwing exception when receiving invalid SqlNotificationInfo value #1378

Merged
merged 1 commit into from Nov 17, 2021
Merged

Avoid throwing exception when receiving invalid SqlNotificationInfo value #1378

merged 1 commit into from Nov 17, 2021

Conversation

johnnypham
Copy link
Contributor

@johnnypham johnnypham commented Nov 5, 2021

Addresses #1376

When receiving an invalid SqlNotificationInfo value, an exception would be thrown because the call to Enum.Parse fails. We can use Enum.TryParse to avoid this. The result will still be SqlNotificationInfo.Unknown either way.

@johnnypham johnnypham changed the title Avoid throwing exception when receiving invlaid SqlNotificationInfo value Avoid throwing exception when receiving invalid SqlNotificationInfo value Nov 5, 2021
Copy link

@ascott18 ascott18 left a comment

Choose a reason for hiding this comment

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

I can confirm after testing that the exception is no longer thrown. The "none" attribute value still comes out as "Unknown" as expected, but without having VS break into an exception when exception settings are all enabled and Just My Code is disabled.

@cheenamalhotra cheenamalhotra added this to In progress in SqlClient v4.0 via automation Nov 12, 2021
@cheenamalhotra cheenamalhotra added this to the 4.0.0 milestone Nov 12, 2021
@cheenamalhotra
Copy link
Member

Can you add a test case here to cover this code block?

@johnnypham
Copy link
Contributor Author

Can you add a test case here to cover this code block?

I was unable to reproduce it but this is a server-side bug so it shouldn't be occurring. If it does, we'll avoid throwing an unnecessary exception.

SqlClient v4.0 automation moved this from In progress to Reviewer approved Nov 17, 2021
@cheenamalhotra cheenamalhotra merged commit 397279b into dotnet:main Nov 17, 2021
SqlClient v4.0 automation moved this from Reviewer approved to Done Nov 17, 2021
@johnnypham johnnypham mentioned this pull request Nov 18, 2021
@johnnypham johnnypham deleted the SqlNotificationInfo1376 branch November 18, 2021 23:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

5 participants