Class JSONRPC2ExtendedError
- java.lang.Object
-
- java.lang.Throwable
-
- java.lang.Exception
-
- com.thetransactioncompany.jsonrpc2.JSONRPC2Error
-
- net.i2p.i2pcontrol.servlets.jsonrpc2handlers.JSONRPC2ExtendedError
-
- All Implemented Interfaces:
Serializable
public class JSONRPC2ExtendedError extends JSONRPC2Error
Represents a JSON-RPC 2.0 error that occured during the processing of a request.The protocol expects error objects to be structured like this:
code
An integer that indicates the error type.message
A string providing a short description of the error. The message should be limited to a concise single sentence.data
Additional 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 ofjava.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_ERROR
JSON parse error (-32700)JSONRPC2Error.INVALID_REQUEST
Invalid JSON-RPC 2.0 Request (-32600)JSONRPC2Error.METHOD_NOT_FOUND
Method not found (-32601)JSONRPC2Error.INVALID_PARAMS
Invalid parameters (-32602)JSONRPC2Error.INTERNAL_ERROR
Internal 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.
- Version:
- 1.16 (2010-10-04)
- Author:
- Vladimir Dzhuvinov
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static JSONRPC2Error
INVALID_PASSWORD
Invalid JSON-RPC 2.0, implementation defined error (-32099 ..static JSONRPC2Error
INVALID_TOKEN
Invalid JSON-RPC 2.0, implementation defined error (-32099 ..static JSONRPC2Error
NO_TOKEN
Invalid JSON-RPC 2.0, implementation defined error (-32099 ..static JSONRPC2Error
TOKEN_EXPIRED
Invalid JSON-RPC 2.0, implementation defined error (-32099 ..static JSONRPC2Error
UNSPECIFIED_API_VERSION
Invalid JSON-RPC 2.0, implementation defined error (-32099 ..static JSONRPC2Error
UNSUPPORTED_API_VERSION
Invalid JSON-RPC 2.0, implementation defined error (-32099 ..-
Fields inherited from class com.thetransactioncompany.jsonrpc2.JSONRPC2Error
INTERNAL_ERROR, INVALID_PARAMS, INVALID_REQUEST, METHOD_NOT_FOUND, PARSE_ERROR
-
-
Constructor Summary
Constructors Constructor Description JSONRPC2ExtendedError(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 com.thetransactioncompany.jsonrpc2.JSONRPC2Error
appendMessage, appendMessage, equals, getCode, getData, setData, setData, toJSON, toJSONObject, toString
-
Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace
-
-
-
-
Field Detail
-
INVALID_PASSWORD
public static final JSONRPC2Error INVALID_PASSWORD
Invalid JSON-RPC 2.0, implementation defined error (-32099 .. -32000)
-
NO_TOKEN
public static final JSONRPC2Error NO_TOKEN
Invalid JSON-RPC 2.0, implementation defined error (-32099 .. -32000)
-
INVALID_TOKEN
public static final JSONRPC2Error INVALID_TOKEN
Invalid JSON-RPC 2.0, implementation defined error (-32099 .. -32000)
-
TOKEN_EXPIRED
public static final JSONRPC2Error TOKEN_EXPIRED
Invalid JSON-RPC 2.0, implementation defined error (-32099 .. -32000)
-
UNSPECIFIED_API_VERSION
public static final JSONRPC2Error UNSPECIFIED_API_VERSION
Invalid JSON-RPC 2.0, implementation defined error (-32099 .. -32000)
-
UNSUPPORTED_API_VERSION
public static final JSONRPC2Error UNSUPPORTED_API_VERSION
Invalid JSON-RPC 2.0, implementation defined error (-32099 .. -32000)
-
-
Constructor Detail
-
JSONRPC2ExtendedError
public JSONRPC2ExtendedError(int code, String message)
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
public JSONRPC2ExtendedError(int code, String message, Object data)
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.
-
-