# `AshTypescript.Rpc.Error`
[🔗](https://github.com/ash-project/ash_typescript/blob/v0.17.3/lib/ash_typescript/rpc/error.ex#L5)

Protocol for extracting minimal information from exceptions for RPC responses.

Similar to AshGraphql.Error, this protocol transforms various error types into
a standardized format with only the essential information needed by TypeScript clients.

## Error Format

Each implementation should return a map with these fields:
- `:message` - The full error message (may contain template variables like %{key})
- `:short_message` - A concise version of the message
- `:type` - A machine-readable error type (e.g., "invalid_changes", "not_found")
- `:vars` - A map of variables to interpolate into messages
- `:fields` - A list of affected field names (for field-level errors)
- `:path` - The path to the error location in the data structure
- `:details` - An optional map with extra details

## Example Implementation

    defimpl AshTypescript.Rpc.Error, for: MyApp.CustomError do
      def to_error(error) do
        %{
          message: error.message,
          short_message: "Custom error occurred",
          type: "custom_error",
          vars: %{detail: error.detail},
          fields: [],
          path: error.path || []
        }
      end
    end

# `t`

```elixir
@type t() :: term()
```

All the types that implement this protocol.

# `to_error`

```elixir
@spec to_error(Exception.t()) :: map()
```

Transforms an exception into a minimal error representation for RPC responses.

---

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