Search in sources :

Example 1 with AS2ProcessorException

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);
}
Also used : AS2Exception(com.helger.as2lib.exception.AS2Exception) AS2ProcessorException(com.helger.as2lib.processor.AS2ProcessorException) Nonnull(javax.annotation.Nonnull)

Aggregations

AS2Exception (com.helger.as2lib.exception.AS2Exception)1 AS2ProcessorException (com.helger.as2lib.processor.AS2ProcessorException)1 Nonnull (javax.annotation.Nonnull)1