Skip to content

Instantly share code, notes, and snippets.

@explorer14
Created January 14, 2020 17:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save explorer14/d6a2e67e92056120f80688ad0571ef6c to your computer and use it in GitHub Desktop.
Save explorer14/d6a2e67e92056120f80688ad0571ef6c to your computer and use it in GitHub Desktop.
public static class MySqlExceptionExtensions
{
public static bool IsFailoverException(this MySqlException mySqlException)
{
return mySqlException.Number == (int)MySqlErrorCode.UnableToConnectToHost ||
mySqlException.Number == (int)MySqlErrorCode.OptionPreventsStatement ||
(mySqlException.Number == 0 && mySqlException.HResult == -2147467259);
// Fatal error reading from the stream, usually Number being 0 means host connection issues
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment