# `A2A.JSONRPC.Error`
[🔗](https://github.com/actioncard/a2a-elixir/blob/main/lib/a2a/jsonrpc/error.ex#L1)

JSON-RPC 2.0 error with A2A-specific error codes.

Provides a struct and named constructors for the 14 error codes defined by
the A2A protocol (5 standard JSON-RPC + 9 A2A-specific).

A2A-specific errors (-32001..-32009) serialize with a `google.rpc.ErrorInfo`
object inside a `"data"` array, as the spec requires. The 5 standard JSON-RPC
codes have no defined `reason` and keep their free-form `data`.

## Example

    iex> error = A2A.JSONRPC.Error.task_not_found()
    iex> error.code
    -32001
    iex> A2A.JSONRPC.Error.to_map(error)
    %{
      "code" => -32001,
      "message" => "Task not found",
      "data" => [
        %{
          "@type" => "type.googleapis.com/google.rpc.ErrorInfo",
          "domain" => "a2a-protocol.org",
          "reason" => "TASK_NOT_FOUND"
        }
      ]
    }

# `t`

```elixir
@type t() :: %A2A.JSONRPC.Error{code: integer(), data: term(), message: String.t()}
```

# `authenticated_extended_card_not_configured`

```elixir
@spec authenticated_extended_card_not_configured(term()) :: t()
```

Builds an authenticated extended card not configured error (-32007).

# `content_type_not_supported`

```elixir
@spec content_type_not_supported(term()) :: t()
```

Builds a content type not supported error (-32005).

# `extension_support_required`

```elixir
@spec extension_support_required(term()) :: t()
```

Builds an extension support required error (-32008).

# `internal_error`

```elixir
@spec internal_error(term()) :: t()
```

Builds an internal error (-32603).

# `invalid_agent_response`

```elixir
@spec invalid_agent_response(term()) :: t()
```

Builds an invalid agent response error (-32006).

# `invalid_params`

```elixir
@spec invalid_params(term()) :: t()
```

Builds an invalid params error (-32602).

# `invalid_request`

```elixir
@spec invalid_request(term()) :: t()
```

Builds an invalid request error (-32600).

# `method_not_found`

```elixir
@spec method_not_found(term()) :: t()
```

Builds a method not found error (-32601).

# `parse_error`

```elixir
@spec parse_error(term()) :: t()
```

Builds a parse error (-32700).

# `push_notification_not_supported`

```elixir
@spec push_notification_not_supported(term()) :: t()
```

Builds a push notification not supported error (-32003).

# `task_not_cancelable`

```elixir
@spec task_not_cancelable(term()) :: t()
```

Builds a task not cancelable error (-32002).

# `task_not_found`

```elixir
@spec task_not_found(term()) :: t()
```

Builds a task not found error (-32001).

# `to_map`

```elixir
@spec to_map(t()) :: map()
```

Converts an error struct to a JSON-ready map.

For A2A-specific codes (-32001..-32009) `"data"` is always an array carrying
a `google.rpc.ErrorInfo` object; any free-form data is preserved under its
`"metadata"`. For standard JSON-RPC codes `"data"` is passed through as-is
and omitted when nil.

    iex> error = A2A.JSONRPC.Error.internal_error("boom")
    iex> A2A.JSONRPC.Error.to_map(error)
    %{"code" => -32603, "message" => "Internal error", "data" => "boom"}

# `unsupported_operation`

```elixir
@spec unsupported_operation(term()) :: t()
```

Builds an unsupported operation error (-32004).

# `version_not_supported`

```elixir
@spec version_not_supported(term()) :: t()
```

Builds a version not supported error (-32009).

---

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