# `ExMCP.Client.Error`
[🔗](https://github.com/azmaveth/ex_mcp/blob/v1.0.0/lib/ex_mcp/client/error.ex#L1)

Enhanced error formatting and actionable guidance for MCP.

This module transforms low-level MCP protocol errors into developer-friendly
error messages with actionable guidance and debugging context.

## Features

- Human-readable error descriptions
- Actionable troubleshooting steps
- Context preservation for debugging
- Error categorization and severity levels
- Common error pattern recognition

## Error Categories

- **Connection**: Transport and connectivity issues
- **Protocol**: MCP protocol violations or mismatches
- **Authentication**: Auth and permission problems
- **Resource**: Tool/resource/prompt related errors
- **Timeout**: Request timeout and performance issues
- **Validation**: Input validation and schema errors

# `error_category`

```elixir
@type error_category() ::
  :connection
  | :protocol
  | :authentication
  | :resource
  | :timeout
  | :validation
  | :internal
  | :unknown
```

# `error_severity`

```elixir
@type error_severity() :: :low | :medium | :high | :critical
```

# `formatted_error`

```elixir
@type formatted_error() :: %{
  type: atom(),
  category: error_category(),
  severity: error_severity(),
  message: String.t(),
  details: String.t() | nil,
  suggestions: [String.t()],
  context: map(),
  original_error: any()
}
```

# `format`

```elixir
@spec format(atom(), any(), map()) :: formatted_error()
```

Formats an error with enhanced context and actionable guidance.

## Examples

    Error.format(:tool_call_failed, :timeout, %{tool: "slow_tool", args: %{}})
    # => %{
    #   type: :tool_call_failed,
    #   category: :timeout,
    #   severity: :medium,
    #   message: "Tool call to 'slow_tool' timed out",
    #   suggestions: ["Increase timeout value", "Check tool performance"],
    #   context: %{tool: "slow_tool", args: %{}}
    # }

# `format_suggestions`

```elixir
@spec format_suggestions([String.t()]) :: String.t()
```

Formats suggestions as a readable list.

# `get_suggestions`

```elixir
@spec get_suggestions(formatted_error()) :: [String.t()]
```

Gets troubleshooting suggestions for an error.

# `summarize`

```elixir
@spec summarize(formatted_error()) :: String.t()
```

Creates a user-friendly error summary for display.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
