public void setException(Throwable t) {
        if (t != null) {
            if (t instanceof ReadTimeoutException) {
                error = "READ_TIMEOUT";
                exceptionType = t.getClass().getSimpleName();
            } else if (t instanceof OriginConnectException oce) {
                if (oce.getErrorType() != null) {
                    error = oce.getErrorType().toString();
                } else {
                    error = "ORIGIN_CONNECT_ERROR";
                }

                Throwable oceCause = oce.getCause();

                // unwrap ssl handshake exceptions to emit the underlying handshake failure causes
                if (oceCause instanceof SSLHandshakeException sslHandshakeException
                        && sslHandshakeException.getCause() != null) {
                    oceCause = sslHandshakeException.getCause();
                }

                if (oceCause != null) {
                    exceptionType = oce.getCause().getClass().getSimpleName();
                    cause = oceCause.getMessage();
                } else {
                    exceptionType = oce.getClass().getSimpleName();
                }

            } else if (t instanceof OutboundException obe) {
                error = obe.getOutboundErrorType().toString();
                exceptionType = OutboundException.class.getSimpleName();
            } else if (t instanceof SSLHandshakeException) {
                error = t.getMessage();
                exceptionType = t.getClass().getSimpleName();
                cause = t.getCause().getMessage();
            } else {
                error = t.getMessage();
                exceptionType = t.getClass().getSimpleName();

                // for unexpected exceptions, just capture the first line of the stacktrace
                // otherwise we risk large stacktraces in memory and metrics systems
                StackTraceElement[] stackTraceElements = t.getStackTrace();
                if (stackTraceElements.length > 0) {
                    cause = stackTraceElements[0].toString();
                }
            }
        }
    }
User: michaels@netflix.com
Date: 9/2/14
Time: 2:52 PM
zuul-core/src/main/java/com/netflix/zuul/niws/RequestAttempt.java