@SuppressWarnings("PMD.AvoidDeeplyNestedIfStmts")
    protected boolean isSqlState(String expectedSqlState, Throwable throwable) {
        Throwable t = throwable;
        while (t != null) {
            if (t instanceof SQLException) {
                Iterator<Throwable> unnestIterator = ((SQLException) t).iterator();
                while (unnestIterator.hasNext()) {
                    Throwable next = unnestIterator.next();
                    if (next instanceof SQLException) {
                        SQLException s = (SQLException) next;
                        String sqlState = s.getSQLState();
                        if (sqlState != null && sqlState.startsWith(expectedSqlState)) {
                            return true;
                        }
                    }
                }
                return false;
            }
            t = t.getCause();
        }

        return false;
    }
Checks whether a given exception is in a specific SQL state.

@param expectedSqlState The expected SQL state.
@param throwable The Throwable to test.
@return True if Throwable or one of its causes is an SQLException whose SQLState begins with the given state.
core/src/main/java/org/jdbi/v3/core/transaction/SerializableTransactionRunner.java