0

I'm writing my app with NET Standard 2.1 and MySql (NuGet pack MySql.Data). The MySqlException doesn't have the property IsTransient so I can't recognize if the exception is temporary. How can I manage this? Is there a list of error code that are transient? I can't find it.

Thanks

1 Answer 1

0

If switching NuGet packages is an option for you, the MySqlConnector package (disclaimer: I'm the lead author) implements this property: https://github.com/mysql-net/MySqlConnector/issues/849

Otherwise, you could borrow its logic:

public static bool IsTransient(MySqlException ex) => (MySqlErrorCode) ex.Code
    is MySqlErrorCode.ConnectionCountError
    or MySqlErrorCode.LockDeadlock
    or MySqlErrorCode.LockWaitTimeout
    or MySqlErrorCode.UnableToConnectToHost
    or MySqlErrorCode.XARBDeadlock
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.