Package io.quarkus.websockets.next
Annotation Interface OnError
WebSocket and WebSocketClient endpoint methods annotated with this annotation are invoked when an error
occurs.
It is used when an endpoint callback throws a runtime error, or when a conversion errors occurs, or when a returned
Uni receives a failure. An endpoint may declare multiple methods annotated with this annotation.
However, each method must declare a different error
parameter. The method that declares a most-specific supertype of the actual exception is selected.
Execution model
- Methods annotated with
RunOnVirtualThreadare considered blocking and should be executed on a virtual thread. - Methods annotated with
Blockingare considered blocking and should be executed on a worker thread. - Methods annotated with
NonBlockingare considered non-blocking and should be executed on an event loop thread.
- Methods returning
voidare considered blocking and should be executed on a worker thread. - Methods returning
UniorMultiare considered non-blocking and should be executed on an event loop thread. - Methods returning any other type are considered blocking and should be executed on a worker thread.
Method parameters
The method must accept exactly one "error" parameter, i.e. a parameter that is assignable fromThrowable.
The method may also accept the following parameters:
WebSocketConnection/WebSocketClientConnection; depending on the endpoint typeHandshakeRequestStringparameters annotated withPathParam
Global error handlers
This annotation can be also used to declare a global error handler, i.e. a method that is not declared on aWebSocket/WebSocketClient endpoint. Such a method may not accept PathParam paremeters. If a global
error handler accepts WebSocketConnection then it's only applied to server-side errors. If a global error
handler accepts WebSocketClientConnection then it's only applied to client-side errors.
Error handlers declared on an endpoint take precedence over the global error handlers.