TrueZIP Kernel 7.0-rc1

de.schlichtherle.truezip.util
Interface ExceptionBuilder<C extends Exception,E extends Exception>

Type Parameters:
C - The type of the cause exception.
E - The type of the assembled exception.
All Superinterfaces:
ExceptionHandler<C,E>
All Known Implementing Classes:
AbstractExceptionBuilder, ChainableIOExceptionBuilder, FsSyncExceptionBuilder

@NotThreadSafe
public interface ExceptionBuilder<C extends Exception,E extends Exception>
extends ExceptionHandler<C,E>

An exception builder is an exception handler which assembles an exception of the parameter type T from one or more exceptions of the parameter type C. This may be used in scenarios where a cooperative algorithm needs to continue its task even if one or more exceptional conditions occur. This interface would then allow to collect all cause exceptions during the processing by calling warn(Exception) and later check out the assembled exception by calling fail(Exception) or check().

Author:
Christian Schlichtherle

Method Summary
 void check()
          Either returns or checks out and throws the result of the assembly in order to enable the assembly of another exception.
 E fail(C cause)
          Adds the cause exception to the assembly and checks out and returns the result in order to enable the assembly of another exception.
 void warn(C cause)
          Adds the cause exception to the assembly and either returns or checks out and throws the result in order to enable the assembly of another exception.
 

Method Detail

fail

@NonNull
E fail(@NonNull
               C cause)
Adds the cause exception to the assembly and checks out and returns the result in order to enable the assembly of another exception.

Called to handle an exceptional condition which does not allow the caller to proceed its task. The implementation must return an appropriate exception to be thrown by the cooperative algorithm. Finally, if the implementation maintains a state, it must be updated so that this instance can be reused to handle more exceptions!

Specified by:
fail in interface ExceptionHandler<C extends Exception,E extends Exception>
Parameters:
cause - the exception to handle.
Returns:
The assembled exception to throw.

warn

void warn(@NonNull
          C cause)
          throws E extends Exception
Adds the cause exception to the assembly and either returns or checks out and throws the result in order to enable the assembly of another exception.

Called to handle an exceptional condition which does allow the caller to proceed its task. The implementation may throw an exception of the parameter type T or return from the call. If the implementation maintains a state, it must be updated so that this instance can be reused to handle more exceptions.

Specified by:
warn in interface ExceptionHandler<C extends Exception,E extends Exception>
Parameters:
cause - the exception to handle - null is not permitted.
Throws:
Exception - the assembled exception if the implementation wants the caller to abort its task.

check

void check()
           throws E extends Exception
Either returns or checks out and throws the result of the assembly in order to enable the assembly of another exception.

Throws:
Exception - the assembled exception if the implementation wants the caller to abort its task.

TrueZIP Kernel 7.0-rc1

Copyright © 2005-2011 Schlichtherle IT Services. All Rights Reserved.