public interface JsonRpcError
A representation of a JSON-RPC error.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intInternal JSON-RPC error.static final intInvalid method parameter(s).static final intThe JSON sent is not a valid Request object.static final intThe method does not exist or is not available.static final intInvalid JSON was received by the server. -
Method Summary
Modifier and TypeMethodDescriptionAccess the error as a JSON object.intcode()Get the code for this error.static JsonRpcErrorCreate an instance from a code and a message.static JsonRpcErrorCreate an instance from a code, a message and data.static JsonRpcErrorcreate(JsonObject error) Create an instance from a JSON object.data()Get the data associated with this error, if defined.<T> Optional<T> Get the data associated with this error as an object, if defined.message()Get the message for this error.
-
Field Details
-
PARSE_ERROR
static final int PARSE_ERRORInvalid JSON was received by the server.- See Also:
-
INVALID_REQUEST
static final int INVALID_REQUESTThe JSON sent is not a valid Request object.- See Also:
-
METHOD_NOT_FOUND
static final int METHOD_NOT_FOUNDThe method does not exist or is not available.- See Also:
-
INVALID_PARAMS
static final int INVALID_PARAMSInvalid method parameter(s).- See Also:
-
INTERNAL_ERROR
static final int INTERNAL_ERRORInternal JSON-RPC error.- See Also:
-
-
Method Details
-
create
Create an instance from a JSON object.- Parameters:
error- the object- Returns:
- a new instance of this class
-
create
Create an instance from a code and a message.- Parameters:
code- the error codemessage- the message- Returns:
- a new instance of this class
-
create
Create an instance from a code, a message and data.- Parameters:
code- the error codemessage- the messagedata- the associated data- Returns:
- a new instance of this class
-
code
int code()Get the code for this error.- Returns:
- the code
-
message
String message()Get the message for this error.- Returns:
- the message
-
data
Get the data associated with this error, if defined.- Returns:
- optional data
-
dataAs
Get the data associated with this error as an object, if defined. This method will use JSONB for binding.- Type Parameters:
T- the bean type- Parameters:
type- the bean class- Returns:
- optional data
- Throws:
ClassCastException- if the data is not a JSON objectJsonbException- if an error occurs during mapping
-
asJsonObject
JsonObject asJsonObject()Access the error as a JSON object.- Returns:
- a JSON object
-