public static TDClientException defaultExceptionResolver(Exception e)
            throws TDClientException
    {
        if (TDClientException.class.isAssignableFrom(e.getClass())) {
            // If the error is known error, we should throw it as is
            throw (TDClientException) e;
        }
        else if (e instanceof ProtocolException || e instanceof ConnectException || e instanceof EOFException) {
            // OkHttp throws ProtocolException the content length is insufficient
            // ConnectionException can be throw if server is shutting down
            // EOFException can be thrown when the connection was interrupted
            return new TDClientInterruptedException("connection failure", e);
        }
        else if (e instanceof TimeoutException || e instanceof SocketTimeoutException) {
            // OkHttp throws SocketTimeoutException
            return new TDClientTimeoutException(e);
        }
        else if (e instanceof SocketException) {
            final SocketException socketException = (SocketException) e;
            if (socketException instanceof BindException ||
                    socketException instanceof ConnectException ||
                    socketException instanceof NoRouteToHostException ||
                    socketException instanceof PortUnreachableException) {
                // All known SocketException are retryable.
                return new TDClientSocketException(socketException);
            }
            else {
                // Other unknown SocketException are considered non-retryable.
                throw new TDClientSocketException(socketException);
            }
        }
        else if (e instanceof SSLException) {
            SSLException sslException = (SSLException) e;
            if (sslException instanceof SSLHandshakeException || sslException instanceof SSLKeyException || sslException instanceof SSLPeerUnverifiedException) {
                // deterministic SSL exceptions
                throw new TDClientSSLException(sslException);
            }
            else {
                // SSLProtocolException and uncategorized SSL exceptions (SSLException) such as unexpected_message may be retryable
                return new TDClientSSLException(sslException);
            }
        }
        else if (e.getCause() != null && Exception.class.isAssignableFrom(e.getCause().getClass())) {
            return defaultExceptionResolver((Exception) e.getCause());
        }
        else {
            logger.warn("unknown type exception: " + e.getClass(), e);
            throw new TDClientProcessingException(e);
        }
    }
public static TDClientException defaultExceptionResolver ( Exception e ) throws TDClientException { if ( TDClientException . class . isAssignableFrom ( e . getClass ( ) ) ) { throw ( TDClientException ) e ; } else if ( e instanceof ProtocolException || e instanceof ConnectException || e instanceof EOFException ) { return new TDClientInterruptedException ( "connection failure" , e ) ; } else if ( e instanceof TimeoutException || e instanceof SocketTimeoutException ) { return new TDClientTimeoutException ( e ) ; } else if ( e instanceof SocketException ) { final SocketException socketException = ( SocketException ) e ; if ( socketException instanceof BindException || socketException instanceof ConnectException || socketException instanceof NoRouteToHostException || socketException instanceof PortUnreachableException ) { return new TDClientSocketException ( socketException ) ; } else { throw new TDClientSocketException ( socketException ) ; } } else if ( e instanceof SSLException ) { SSLException sslException = ( SSLException ) e ; if ( sslException instanceof SSLHandshakeException || sslException instanceof SSLKeyException || sslException instanceof SSLPeerUnverifiedException ) { throw new TDClientSSLException ( sslException ) ; } else { return new TDClientSSLException ( sslException ) ; } } else if ( e . getCause ( ) != null && Exception . class . isAssignableFrom ( e . getCause ( ) . getClass ( ) ) ) { return defaultExceptionResolver ( ( Exception ) e . getCause ( ) ) ; } else { logger . warn ( "unknown type exception: " + e . getClass ( ) , e ) ; throw new TDClientProcessingException ( e ) ; } }
@return If the error type is retryable, return the exception. If not, throw it as TDClientException
@throws TDClientException