Class McpException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
dev.langchain4j.exception.LangChain4jException
dev.langchain4j.mcp.client.McpException
- All Implemented Interfaces:
Serializable
A business exception raised over the MCP protocol
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint@Nullable StringReturns the JSON-RPCerror.datamember as JSON text.Returns the JSON-RPCerror.datamember as plain values, so callers do not need a JSON library.@Nullable Objectstatic McpExceptionwithErrorData(int errorCode, String errorMessage, @Nullable String errorDataAsJson) Creates an exception carrying the JSON-RPCerror.datamember as JSON text, or no data whenerrorDataAsJsonis null.Methods inherited from class Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Constructor Details
-
McpException
-
-
Method Details
-
withErrorData
public static McpException withErrorData(int errorCode, String errorMessage, @Nullable String errorDataAsJson) Creates an exception carrying the JSON-RPCerror.datamember as JSON text, or no data whenerrorDataAsJsonis null. -
errorCode
public int errorCode() -
errorMessage
-
errorDataAsJson
Returns the JSON-RPCerror.datamember as JSON text. -
errorDataAsMap
Returns the JSON-RPCerror.datamember as plain values, so callers do not need a JSON library.- Returns:
- null when there is no
error.data, and also when it is not a JSON object - JSON-RPC allows any value there. UseerrorDataAsObject()to read those.
-
errorDataAsObject
-