Class ThrowableCollector

    • Constructor Detail

      • ThrowableCollector

        public ThrowableCollector​(Predicate<? super Throwable> abortedExecutionPredicate)
        Create a new ThrowableCollector that uses the supplied Predicate to determine whether a Throwable aborted or failed execution.
        Parameters:
        abortedExecutionPredicate - the predicate used to decide whether a Throwable aborted execution; never null.
    • Method Detail

      • getThrowable

        public Throwable getThrowable()
        Get the first Throwable collected by this ThrowableCollector.

        If this collector is not empty, the first collected Throwable will be returned with any additional Throwables suppressed in the first Throwable.

        If the first collected Throwable aborted execution and at least one later collected Throwable failed execution, the first failing Throwable will be returned with the previous aborting and any additional Throwables suppressed inside.

        Returns:
        the first collected Throwable or null if this ThrowableCollector is empty
        See Also:
        isEmpty(), assertEmpty()
      • isEmpty

        public boolean isEmpty()
        Determine if this ThrowableCollector is empty (i.e., has not collected any Throwables).
      • isNotEmpty

        public boolean isNotEmpty()
        Determine if this ThrowableCollector is not empty (i.e., has collected at least one Throwable).
      • assertEmpty

        public void assertEmpty()
        Assert that this ThrowableCollector is empty (i.e., has not collected any Throwables).

        If this collector is not empty, the first collected Throwable will be thrown with any additional Throwables suppressed in the first Throwable. Note, however, that the Throwable will not be wrapped. Rather, it will be masked as an unchecked exception.

        See Also:
        getThrowable(), ExceptionUtils.throwAsUncheckedException(Throwable)