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).