当前位置: 首页>>代码示例>>Java>>正文


Java ExceptionUtils.getThrowableList方法代码示例

本文整理汇总了Java中org.apache.commons.lang3.exception.ExceptionUtils.getThrowableList方法的典型用法代码示例。如果您正苦于以下问题:Java ExceptionUtils.getThrowableList方法的具体用法?Java ExceptionUtils.getThrowableList怎么用?Java ExceptionUtils.getThrowableList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.lang3.exception.ExceptionUtils的用法示例。


在下文中一共展示了ExceptionUtils.getThrowableList方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: map

import org.apache.commons.lang3.exception.ExceptionUtils; //导入方法依赖的package包/类
@Override
public BackgroundException map(final IOException failure) {
    final Throwable[] stack = ExceptionUtils.getThrowables(failure);
    for(Throwable t : stack) {
        if(t instanceof BackgroundException) {
            return (BackgroundException) t;
        }
    }
    if(failure instanceof SSLException) {
        return new SSLExceptionMappingService().map((SSLException) failure);
    }
    final StringBuilder buffer = new StringBuilder();
    this.append(buffer, failure.getMessage());
    for(Throwable cause : ExceptionUtils.getThrowableList(failure)) {
        if(!StringUtils.contains(failure.getMessage(), cause.getMessage())) {
            this.append(buffer, cause.getMessage());
        }
    }
    return this.wrap(failure, buffer);
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:21,代码来源:DefaultIOExceptionMappingService.java

示例2: determine

import org.apache.commons.lang3.exception.ExceptionUtils; //导入方法依赖的package包/类
@Override
public Type determine(final BackgroundException failure) {
    if(log.isDebugEnabled()) {
        log.debug(String.format("Determine cause for failure %s", failure));
    }
    if(failure instanceof ConnectionTimeoutException) {
        return Type.network;
    }
    if(failure instanceof ConnectionRefusedException) {
        return Type.network;
    }
    if(failure instanceof ResolveFailedException) {
        return Type.network;
    }
    if(failure instanceof SSLNegotiateException) {
        return Type.application;
    }
    for(Throwable cause : ExceptionUtils.getThrowableList(failure)) {
        if(cause instanceof SSLException) {
            return Type.network;
        }
        if(cause instanceof NoHttpResponseException) {
            return Type.network;
        }
        if(cause instanceof ConnectTimeoutException) {
            return Type.network;
        }
        if(cause instanceof SocketException
                || cause instanceof TimeoutException // Used in Promise#retrieve
                || cause instanceof SocketTimeoutException
                || cause instanceof UnknownHostException) {
            return Type.network;
        }
    }
    return Type.application;
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:37,代码来源:DefaultFailureDiagnostics.java

示例3: wrap

import org.apache.commons.lang3.exception.ExceptionUtils; //导入方法依赖的package包/类
protected BackgroundException wrap(final T failure, final String title, final StringBuilder buffer) {
    if(buffer.toString().isEmpty()) {
        log.warn(String.format("No message for failure %s", failure));
        this.append(buffer, LocaleFactory.localizedString("Interoperability failure", "Error"));
    }
    for(Throwable cause : ExceptionUtils.getThrowableList(failure)) {
        if(cause instanceof InterruptedIOException) {
            // Handling socket timeouts
            return new ConnectionTimeoutException(buffer.toString(), failure);
        }
        if(cause instanceof TimeoutException) {
            //
            return new ConnectionTimeoutException(buffer.toString(), failure);
        }
        if(cause instanceof SocketException) {
            return new DefaultSocketExceptionMappingService().map((SocketException) cause);
        }
        if(cause instanceof EOFException) {
            return new ConnectionRefusedException(buffer.toString(), failure);
        }
        if(cause instanceof UnknownHostException) {
            return new ResolveFailedException(buffer.toString(), failure);
        }
        if(cause instanceof NoHttpResponseException) {
            return new ConnectionRefusedException(buffer.toString(), failure);
        }
    }
    return new BackgroundException(title, buffer.toString(), failure);
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:30,代码来源:AbstractExceptionMappingService.java

示例4: map

import org.apache.commons.lang3.exception.ExceptionUtils; //导入方法依赖的package包/类
/**
 * close_notify(0),
 * unexpected_message(10),
 * bad_record_mac(20),
 * decryption_failed_RESERVED(21),
 * record_overflow(22),
 * decompression_failure(30),
 * handshake_failure(40),
 * no_certificate_RESERVED(41),
 * bad_certificate(42),
 * unsupported_certificate(43),
 * certificate_revoked(44),
 * certificate_expired(45),
 * certificate_unknown(46),
 * illegal_parameter(47),
 * unknown_ca(48),
 * access_denied(49),
 * decode_error(50),
 * decrypt_error(51),
 * export_restriction_RESERVED(60),
 * protocol_version(70),
 * insufficient_security(71),
 * internal_error(80),
 * user_canceled(90),
 * no_renegotiation(100),
 * unsupported_extension(110),
 */
@Override
public BackgroundException map(final SSLException failure) {
    final StringBuilder buffer = new StringBuilder();
    for(Throwable cause : ExceptionUtils.getThrowableList(failure)) {
        if(cause instanceof SocketException) {
            // Map Connection has been shutdown: javax.net.ssl.SSLException: java.net.SocketException: Broken pipe
            return new DefaultSocketExceptionMappingService().map((SocketException) cause);
        }
    }
    final String message = failure.getMessage();
    for(Alert alert : Alert.values()) {
        if(StringUtils.contains(message, alert.name())) {
            this.append(buffer, alert.getDescription());
            break;
        }
    }
    if(failure instanceof SSLHandshakeException) {
        if(ExceptionUtils.getRootCause(failure) instanceof CertificateException) {
            log.warn(String.format("Ignore certificate failure %s and drop connection", failure.getMessage()));
            // Server certificate not accepted
            return new ConnectionCanceledException(failure);
        }
        return new SSLNegotiateException(buffer.toString(), failure);
    }
    if(ExceptionUtils.getRootCause(failure) instanceof GeneralSecurityException) {
        this.append(buffer, ExceptionUtils.getRootCause(failure).getMessage());
        return new InteroperabilityException(buffer.toString(), failure);
    }
    this.append(buffer, message);
    return new InteroperabilityException(buffer.toString(), failure);
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:59,代码来源:SSLExceptionMappingService.java

示例5: map

import org.apache.commons.lang3.exception.ExceptionUtils; //导入方法依赖的package包/类
@Override
public BackgroundException map(final Throwable failure) {
    final StringBuilder buffer = new StringBuilder();
    if(failure instanceof RuntimeException) {
        this.append(buffer, "Unknown application error");
    }
    this.append(buffer, failure.getMessage());
    for(Throwable cause : ExceptionUtils.getThrowableList(failure)) {
        if(!StringUtils.contains(failure.getMessage(), cause.getMessage())) {
            this.append(buffer, cause.getMessage());
        }
    }
    return this.wrap(failure, LocaleFactory.localizedString("Error", "Error"), buffer);
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:15,代码来源:DefaultExceptionMappingService.java


注:本文中的org.apache.commons.lang3.exception.ExceptionUtils.getThrowableList方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。