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

Expose MySqlErrorCode from MySqlException #830

Closed
bgrainger opened this issue Jun 8, 2020 · 0 comments
Closed

Expose MySqlErrorCode from MySqlException #830

bgrainger opened this issue Jun 8, 2020 · 0 comments
Assignees
Milestone

Comments

@bgrainger
Copy link
Member

bgrainger commented Jun 8, 2020

Most MySqlException objects have a corresponding MySqlErrorCode. This is exposed through the public int Number { get; } property, which requires a (non-obvious) cast.

There's a virtual int ErrorCode { get; } property inherited from ExternalException, which appears to always return E_FAIL: https://github.com/dotnet/runtime/blob/master/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/ExternalException.cs

Since this isn't useful, and is already accessible through Exception.HResult, define public new MySqlErrorCode ErrorCode { get; } and return the error code that way.

(Connector/NET adds a confusingly-named Code property that's only defined for the X Protocol: https://stackoverflow.com/a/60293352/23633.)

bgrainger added a commit that referenced this issue Jun 13, 2020
@bgrainger bgrainger self-assigned this Jun 14, 2020
@bgrainger bgrainger added this to the 1.0 milestone Jun 14, 2020
dlemstra added a commit to dlemstra/MySqlConnector that referenced this issue Oct 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

1 participant