Class McpException

All Implemented Interfaces:
Serializable

public class McpException extends LangChain4jException
A business exception raised over the MCP protocol
See Also:
  • Constructor Details

    • McpException

      public McpException(int errorCode, String errorMessage)
  • Method Details

    • withErrorData

      public static McpException withErrorData(int errorCode, String errorMessage, @Nullable String errorDataAsJson)
      Creates an exception carrying the JSON-RPC error.data member as JSON text, or no data when errorDataAsJson is null.
    • errorCode

      public int errorCode()
    • errorMessage

      public String errorMessage()
    • errorDataAsJson

      public @Nullable String errorDataAsJson()
      Returns the JSON-RPC error.data member as JSON text.
    • errorDataAsMap

      public @Nullable Map<String,Object> errorDataAsMap()
      Returns the JSON-RPC error.data member 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. Use errorDataAsObject() to read those.
    • errorDataAsObject

      public @Nullable Object errorDataAsObject()
      Returns the JSON-RPC error.data member as a plain JDK value: a Map, a List, a boxed primitive, or null. JSON-RPC allows error.data to be any value, so this is the accessor that can represent all of them.