public static KerberosError fromException(Exception exception) {
        Throwable cause = exception.getCause();
        while (cause != null && !KRB_EXCEPTION_CLASS.isInstance(cause)) {
            cause = cause.getCause();
        }
        if (cause == null)
            return null;
        else {
            try {
                Integer errorCode = (Integer) KRB_EXCEPTION_RETURN_CODE_METHOD.invoke(cause);
                return fromErrorCode(errorCode);
            } catch (Exception e) {
                log.trace("Kerberos return code could not be determined from {}", exception, e);
                return null;
            }
        }
    }
Kerberos exceptions that may require special handling. The standard Kerberos error codes
for these errors are retrieved using KrbException#errorCode() from the underlying Kerberos
exception thrown during {@link SaslClient#evaluateChallenge(byte[])}.
clients/src/main/java/org/apache/kafka/common/security/kerberos/KerberosError.java