use of com.helger.as2lib.processor.AS2ProcessorException in project as2-lib by phax.
the class AS2DispositionException method wrap.
@Nonnull
public static AS2DispositionException wrap(@Nonnull final Exception ex, @Nonnull final Supplier<DispositionType> aDispositionTypeSupplier, @Nonnull final Supplier<String> aTextSupplier) {
ValueEnforcer.notNull(ex, "Exception");
ValueEnforcer.notNull(aDispositionTypeSupplier, "DispositionTypeSupplier");
ValueEnforcer.notNull(aTextSupplier, "TextSupplier");
if (ex instanceof AS2DispositionException)
return (AS2DispositionException) ex;
if (ex instanceof AS2ProcessorException) {
// Special handling for #130
final ICommonsList<AS2Exception> aCauses = ((AS2ProcessorException) ex).getAllCauses();
if (aCauses.size() == 1) {
final AS2Exception aFirst = aCauses.getFirst();
if (aFirst instanceof AS2DispositionException)
return (AS2DispositionException) aFirst;
}
}
return new AS2DispositionException(aDispositionTypeSupplier.get(), aTextSupplier.get(), ex);
}
Aggregations