Search in sources :

Example 1 with ServerException

use of com.github.shyiko.mysql.binlog.network.ServerException in project debezium by debezium.

the class AbstractReader method wrap.

/**
 * Wraps the specified exception in a {@link ConnectException}, ensuring that all useful state is captured inside
 * the new exception's message.
 *
 * @param error the exception; may not be null
 * @return the wrapped Kafka Connect exception
 */
protected ConnectException wrap(Throwable error) {
    assert error != null;
    String msg = error.getMessage();
    if (error instanceof ServerException) {
        ServerException e = (ServerException) error;
        msg = msg + " Error code: " + e.getErrorCode() + "; SQLSTATE: " + e.getSqlState() + ".";
    } else if (error instanceof SQLException) {
        SQLException e = (SQLException) error;
        msg = e.getMessage() + " Error code: " + e.getErrorCode() + "; SQLSTATE: " + e.getSQLState() + ".";
    }
    return new ConnectException(msg, error);
}
Also used : ServerException(com.github.shyiko.mysql.binlog.network.ServerException) SQLException(java.sql.SQLException) ConnectException(org.apache.kafka.connect.errors.ConnectException)

Aggregations

ServerException (com.github.shyiko.mysql.binlog.network.ServerException)1 SQLException (java.sql.SQLException)1 ConnectException (org.apache.kafka.connect.errors.ConnectException)1