Package org.refcodes.exception
Interface Exceptional<E extends java.lang.Exception>
-
- Type Parameters:
E- the element type
public interface Exceptional<E extends java.lang.Exception>TheExceptionalinterface provides means for threads to wait (sleep) when callingcatchException()till a nextExceptionoccurs or till the waiting (sleeping) threads are released.Usually only
Exceptioninstances are exposed which are occurring inside daemon threads and are usually hidden from the (business) logic. SuchExceptioninstances usually just get logged, no customizable reaction upon such exceptions is possible. This interface enables to react to suchExceptioninstances without the need to overwrite an abstract class's method and without requiring the implementation of an observable interface.It depends on the implementation on how waiting (sleeping) threads are released, this can be established for example upon disposal by invoking
Disposable#dispose()or destruction by invokingDestroyable#destroy().
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidcatchException()This methods awaits anException, usually happening inside a daemon thread and therefore not directly accessible by some (business) logic.ElastException()Returns the last exception which was catchable viacatchException().
-
-
-
Method Detail
-
catchException
void catchException() throws E extends java.lang.Exception, java.lang.IllegalStateExceptionThis methods awaits anException, usually happening inside a daemon thread and therefore not directly accessible by some (business) logic. It waits (sleeps) until anExceptionarises which is then thrown by this method. Upon disposal (Disposable#dispose()) or destruction (Destroyable.destroy()) all waiting threads are continued without throwing any exception. ------------------------------------------------------------------------- ATTENTION: In case waiting (sleeping) threads are released without throwing anException, then this means that the implementing instance intends to shut down so that in such as case, no more calls to this method are to be performed (are to be prevented), such looping threads would lead to endless looping and cause consumption of calculation power. Implementing instances might throw anIllegalStateExceptionexception in case such a status is detected!- Throws:
E- Thrown when a next exception has been provided viaExceptionWatchdog#throwException(Exception)java.lang.IllegalStateException- Thrown in case this method is being called even though the implementing instance has been shut down and has released all threads without throwing an exception.E extends java.lang.Exception
-
lastException
E lastException()
Returns the last exception which was catchable viacatchException().- Returns:
- The last exception being catchable via
catchException();
-
-