本文整理汇总了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);
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}