Package org.apache.juneau.bean.jsonrpc
Class McpException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
org.apache.juneau.bean.jsonrpc.McpException
- All Implemented Interfaces:
Serializable
Runtime exception carrying JSON-RPC error fields for mapping to
JsonRpcError.- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionMcpException(int code, String message) Constructor.McpException(int code, String message, Object data) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionstatic McpExceptionCreates anMcpExceptionfrom aJsonRpcError.intgetCode()JSON-RPC error code.getData()Optional structured error data.setCode(int value) Sets the JSON-RPC error code.Sets optional structured error data.Converts this exception to aJsonRpcError.Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Constructor Details
-
McpException
Constructor.- Parameters:
code- JSON-RPC error code.message- Error message. Can benull to leave the exception message unset.
-
McpException
Constructor.- Parameters:
code- JSON-RPC error code.message- Error message. Can benull to leave the exception message unset.data- Optional structured error data. Can benull to leave the property unset.
-
-
Method Details
-
getCode
JSON-RPC error code.- Returns:
- The code.
-
setCode
Sets the JSON-RPC error code.- Parameters:
value- The new value.- Returns:
- This object (for method chaining).
-
getData
Optional structured error data.- Returns:
- The data, or
nullif not set.
-
setData
Sets optional structured error data.- Parameters:
value- The new value. Can benull to unset the property.- Returns:
- This object (for method chaining).
-
toJsonRpcError
Converts this exception to aJsonRpcError.- Returns:
- A new error object. Never
null.
-
fromJsonRpcError
Creates anMcpExceptionfrom aJsonRpcError.- Parameters:
e- The source error. Must not benull .- Returns:
- A new exception containing the same code, message, and data.
-