presto-raptor-legacy/src/main/java/io/prestosql/plugin/raptor/legacy/util/DatabaseUtil.java/DatabaseUtil/mySqlErrorCodeMatches
class DatabaseUtil:    private static boolean mySqlErrorCodeMatches(Exception e, int errorCode)
    {
        return Throwables.getCausalChain(e).stream()
                .filter(SQLException.class::isInstance)
                .map(SQLException.class::cast)
                .filter(t -> t.getErrorCode() == errorCode)
                .map(Throwable::getStackTrace)
                .anyMatch(isMySQLException());
    }