ExMCP.Error exception (ex_mcp v0.9.0)
View SourceError types and utilities for ExMCP.
This module provides structured error handling with proper error types that can be pattern matched and provide useful debugging information.
Summary
Functions
Creates a protocol error exception with the given JSON-RPC error code.
Creates a transport error exception.
Creates a validation error.
Wraps a function call and converts exceptions to proper error tuples.
Wraps a function call with a custom error transformer.
Types
Functions
Creates a protocol error exception with the given JSON-RPC error code.
Standard JSON-RPC Error Codes
-32700- Parse error-32600- Invalid Request-32601- Method not found-32602- Invalid params-32603- Internal error-32000to-32099- Server error
Creates a transport error exception.
Creates a validation error.
Wraps a function call and converts exceptions to proper error tuples.
Examples
ExMCP.Error.wrap(fn ->
do_something_dangerous()
end)
# => {:ok, result} or {:error, %ExMCP.Error.SomeError{}}
Wraps a function call with a custom error transformer.
Examples
ExMCP.Error.wrap_with(fn ->
read_file(path)
end, fn
{:error, :enoent} -> ExMCP.Error.resource_error(path, :read, :not_found)
error -> error
end)