# `Raxol.AgentClientProtocol.Error`
[🔗](https://github.com/DROOdotFOO/raxol-agent/blob/raxol_agent_client_protocol-v0.1.0/packages/raxol_agent_client_protocol/lib/raxol/agent_client_protocol/error.ex#L1)

JSON-RPC 2.0 error object, plus the ACP-specific vendor error codes.

Standard JSON-RPC 2.0 codes:

  * `-32700` — parse error (malformed JSON)
  * `-32600` — invalid request (well-formed JSON, not a valid Request object)
  * `-32601` — method not found
  * `-32602` — invalid params
  * `-32603` — internal error

ACP-specific codes:

  * `-32000` — authentication required
  * `-32002` — resource not found

Decoding is total: `from_json/1` never raises. Unknown fields on the wire
object are preserved in `_meta` and re-emitted on encode (forward-compat
pass-through), never rejected as an error.

Ported from the MIT `f1729/agent_client_protocol` (c) 2025 f1729; see NOTICE.md.

# `t`

```elixir
@type t() :: %Raxol.AgentClientProtocol.Error{
  _meta: map(),
  code: integer(),
  data: any() | nil,
  message: String.t()
}
```

# `auth_required`

```elixir
@spec auth_required() :: t()
```

# `auth_required_code`

```elixir
@spec auth_required_code() :: integer()
```

# `code_name`

```elixir
@spec code_name(integer()) :: atom() | {:other, integer()}
```

Convert an ErrorCode integer to its name atom, or `{:other, code}` when unrecognized.

# `from_json`

```elixir
@spec from_json(term()) :: {:ok, t()} | {:error, :invalid_error}
```

Decode a JSON-RPC error object. Total: malformed or wrong-shaped input
returns `{:error, :invalid_error}` rather than raising.

# `internal_error`

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

# `internal_error_code`

```elixir
@spec internal_error_code() :: integer()
```

# `invalid_params`

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

# `invalid_params_code`

```elixir
@spec invalid_params_code() :: integer()
```

# `invalid_request`

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

# `invalid_request_code`

```elixir
@spec invalid_request_code() :: integer()
```

# `method_not_found`

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

# `method_not_found_code`

```elixir
@spec method_not_found_code() :: integer()
```

# `new`

```elixir
@spec new(integer(), String.t()) :: t()
```

# `parse_error`

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

# `parse_error_code`

```elixir
@spec parse_error_code() :: integer()
```

# `resource_not_found`

```elixir
@spec resource_not_found(String.t() | nil) :: t()
```

# `resource_not_found_code`

```elixir
@spec resource_not_found_code() :: integer()
```

# `to_json`

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

# `with_data`

```elixir
@spec with_data(t(), any()) :: t()
```

---

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