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

Why there is no value for unable to connect error in MySqlErrorCode #599

Closed
vanbukin opened this issue Dec 25, 2018 · 6 comments
Closed
Assignees

Comments

@vanbukin
Copy link

@vanbukin vanbukin commented Dec 25, 2018

As I see there are two places (here and here) in a whole codebase where that exception could be thrown. So the problem there is no error code for that exception types. And when we want to handle situation when there is no connecton to MySQL database, we need to check the error code (it should be 0) and additionaly check exception message. I think it would be better to add additional enum value into MySqlErrorCode to handle that situation (specially with when clauses).

@bgrainger
Copy link
Member

@bgrainger bgrainger commented Dec 25, 2018

The "why" is mostly oversight and backwards-compatibility with Connector/NET (which also does't have a specific error code for this situation AFAIK).

It seems like we could safely add a new negative enum value, as was done for CommandTimeoutExpired:

/// <summary>
/// The timeout period specified by <see cref="MySqlCommand.CommandTimeout"/> elapsed before the operation completed.
/// </summary>
CommandTimeoutExpired = -1,

@vanbukin
Copy link
Author

@vanbukin vanbukin commented Dec 25, 2018

@bgrainger
Copy link
Member

@bgrainger bgrainger commented Dec 26, 2018

The defined error codes are generally expected to be returned by the server in an error packet.

It's possible that that particular one is reserved for clients to signal connection failure; if so, it would be appropriate to reuse. (Thanks for the pointer.)

@bgrainger
Copy link
Member

@bgrainger bgrainger commented Jan 7, 2019

MySqlErrorCode.UnableToConnectToHost is used by Connector/NET for failure to connect.

@bgrainger
Copy link
Member

@bgrainger bgrainger commented Jan 7, 2019

I wonder if Connector/NET may have co-opted ER_BAD_HOST_ERROR (1042) to mean "can't connect to server"? The "right" client-side error code might be CR_CONNECTION_ERROR (2002) or CR_CONN_HOST_ERROR (2003). Nevertheless, the precedent for .NET is set now.

@bgrainger bgrainger self-assigned this Jan 7, 2019
@bgrainger
Copy link
Member

@bgrainger bgrainger commented Jan 12, 2019

Fixed in 0.49.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants