public class End extends Exception
For example, AsyncIterator.next() either succeeds with the next item,
or fails with an End if there are no more items.
Other APIs, for example ByteSource.read(), also use End
as the control exception, to be compatible with AsyncIterator.next().
Some APIs create subtypes of End to carry more information.
For example, WebSocketClose, a subtype of End,
contains code/reason for the closure of a WebSocket channel inbound/outbound.
Being a control exception, an End does not really represent an exceptional condition;
it is more of a sentinel value for an API.
An End contains no stacktrace and is cheap to create.
It is immutable,
with enableSuppression=writableStackTrace=false,
see explanation in
Throwable(message, cause, enableSuppression, writableStackTrace).
It's safe to share an End object due to immutability.
| Constructor and Description |
|---|
End()
Create an
End exception. |
End(String message)
Create an
End exception. |
End(String message,
Throwable cause)
Create an
End exception. |
| Static Methods | |
|---|---|
End |
instance()
Return an
End instance. |
<T> Async<T> |
async()
Return an `Async<T>` that immediately fails with an
End exception. |
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toStringpublic End()
End exception.public End(String message)
End exception.public static End instance()
End instance.
Semantically equivalent to `new End()`,
but this method may return a cached object.
Example Usage:
action
.then( v->
{
if(condition)
throw End.instance();
...
}
public static <T> Async<T> async()
End exception.
Semantically equivalent to
`Async.failure(new End())`,
but this method may return a cached object.
Often used as a return value in an Async method, for example:
public Async<ByteBuffer> read()
{
if( eof_reached )
return End.async();
...
}