java.lang.Object
java.lang.Throwable
java.lang.Exception
com.thetransactioncompany.jsonrpc2.JSONRPC2Error
net.i2p.i2pcontrol.servlets.jsonrpc2handlers.JSONRPC2ExtendedError
- All Implemented Interfaces:
Serializable
Represents a JSON-RPC 2.0 error that occured during the processing of a request. The implementation defined errors below use the reserved range -32099 .. -32000.
The protocol expects error objects to be structured like this:
codeAn integer that indicates the error type.messageA string providing a short description of the error. The message should be limited to a concise single sentence.dataAdditional information, which may be omitted. Its contents is entirely defined by the application.
Note that the "Error" word in the class name was put there solely to comply with the parlance of the JSON-RPC spec. This class doesn't inherit from java.lang.Error. It's a regular subclass of java.lang.Exception and, if thrown, it's to indicate a condition that a reasonable application might want to catch.
This class also includes convenient final static instances for all standard JSON-RPC 2.0 errors:
JSONRPC2Error.PARSE_ERRORJSON parse error (-32700)JSONRPC2Error.INVALID_REQUESTInvalid JSON-RPC 2.0 Request (-32600)JSONRPC2Error.METHOD_NOT_FOUNDMethod not found (-32601)JSONRPC2Error.INVALID_PARAMSInvalid parameters (-32602)JSONRPC2Error.INTERNAL_ERRORInternal error (-32603)
Note that the range -32099..-32000 is reserved for additional server errors.
The mapping between JSON and Java entities (as defined by the underlying JSON.simple library):
true|false <---> java.lang.Boolean
number <---> java.lang.Number
string <---> java.lang.String
array <---> java.util.List
object <---> java.util.Map
null <---> null
The JSON-RPC 2.0 specification and user group forum can be found here.
- See Also:
Field Summary
Modifier and TypeFieldDescriptionstatic final JSONRPC2ErrorInvalid password provided.static final JSONRPC2ErrorAuthentication token doesn't exist.static final JSONRPC2ErrorNo authentication token presented.private static final longPinned for serialized-form compatibility.static final JSONRPC2ErrorProvided authentication token was expired and will be removed.static final JSONRPC2ErrorThe version of the I2PControl API wasn't specified, but is required to be specified.static final JSONRPC2ErrorThe version of the I2PControl API specified is not supported by I2PControl.Fields inherited from class JSONRPC2Error
INTERNAL_ERROR, INVALID_PARAMS, INVALID_REQUEST, METHOD_NOT_FOUND, PARSE_ERRORModifier and TypeFieldDescriptionstatic final JSONRPC2ErrorInternal JSON-RPC 2.0 error (-32603).static final JSONRPC2ErrorInvalid parameters error (-32602).static final JSONRPC2ErrorInvalid JSON-RPC 2.0 request error (-32600).static final JSONRPC2ErrorMethod not found error (-32601).static final JSONRPC2ErrorJSON parse error (-32700).Constructor Summary
ConstructorsConstructorDescriptionJSONRPC2ExtendedError(int code, String message) Creates a new JSON-RPC 2.0 error with the specified code and message.JSONRPC2ExtendedError(int code, String message, Object data) Creates a new JSON-RPC 2.0 error with the specified code, message and data.Method Summary
Methods inherited from class JSONRPC2Error
appendMessage, equals, getCode, getData, hashCode, setData, toJSONObject, toStringModifier and TypeMethodDescriptionappendMessage(String apx) Appends the specified string to the message of this JSON-RPC 2.0 error.booleanOverridesObject.equals().intgetCode()Gets the JSON-RPC 2.0 error code.getData()Gets the JSON-RPC 2.0 error data.inthashCode()Sets the specified data to a JSON-RPC 2.0 error.Returns a JSON object representation of this JSON-RPC 2.0 error.toString()Serialises the error object to a JSON string.Methods inherited from class Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace
Field Details
serialVersionUID
private static final long serialVersionUIDPinned for serialized-form compatibility.- See Also:
INVALID_PASSWORD
Invalid password provided.NO_TOKEN
No authentication token presented.INVALID_TOKEN
Authentication token doesn't exist.TOKEN_EXPIRED
Provided authentication token was expired and will be removed.UNSPECIFIED_API_VERSION
The version of the I2PControl API wasn't specified, but is required to be specified.UNSUPPORTED_API_VERSION
The version of the I2PControl API specified is not supported by I2PControl.
Constructor Details
JSONRPC2ExtendedError
Creates a new JSON-RPC 2.0 error with the specified code and message. The optional data is omitted.- Parameters:
code- The error code (standard pre-defined or application-specific).message- The error message.
JSONRPC2ExtendedError
Creates a new JSON-RPC 2.0 error with the specified code, message and data.- Parameters:
code- The error code (standard pre-defined or application-specific).message- The error message.data- Optional error data, must map to a valid JSON type.