Hermolaos.Error exception (Hermolaos v0.3.0)

View Source

Exception struct for MCP/JSON-RPC errors.

This exception can be raised when an MCP operation fails with an error response from the server or a client-side error occurs.

Examples

try do
  result = Hermolaos.call_tool(client, "unknown_tool", %{})
rescue
  e in Hermolaos.Error ->
    IO.puts("Tool call failed: #{e.message}")
    IO.puts("Error code: #{e.code}")
end

Summary

Functions

Creates a new Hermolaos.Error from components.

Types

t()

@type t() :: %Hermolaos.Error{
  __exception__: true,
  code: integer(),
  data: term(),
  message: String.t()
}

Functions

new(code, message, data \\ nil)

@spec new(integer(), String.t(), term()) :: t()

Creates a new Hermolaos.Error from components.

Examples

iex> Hermolaos.Error.new(-32601, "Method not found")
%Hermolaos.Error{code: -32601, message: "Method not found", data: nil}