Class ReactiveBlockingException

java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
com.machinezoo.hookless.ReactiveBlockingException
All Implemented Interfaces:
Serializable

public class ReactiveBlockingException extends RuntimeException
Default exception to throw when reactive code needs to reactively block.

Merely creating or throwing this exception is not sufficient to indicate blocking. Current reactive computation must be explicitly marked as blocked before throwing by calling CurrentReactiveScope.block(). This class defines convenience block() method and its overloads that call CurrentReactiveScope.block() before throwing ReactiveBlockingException.

Reactive code should preferably return fallback in case it signals blocking, because that allows the rest of the code to continue and to trigger further blocking operations. This way all blocking operations (e.g. database queries) can execute in parallel.

It is however sometimes impossible to provide a reasonable fallback result. In those cases, throwing an exception is acceptable.

This exception type is provided as the most descriptive for cases of reactive blocking. Its use is not mandatory though. Code that reactively blocks may throw any exception.

See Also: