# `Deputy.Error`
[🔗](https://github.com/sgerrand/ex_deputy/blob/v0.4.0/lib/deputy/error.ex#L1)

Error types for Deputy API client operations.

This module provides standardized error structs for different types of errors that can occur
when interacting with the Deputy API.

# `t`

```elixir
@type t() ::
  Deputy.Error.APIError.t()
  | Deputy.Error.HTTPError.t()
  | Deputy.Error.ParseError.t()
  | Deputy.Error.RateLimitError.t()
  | Deputy.Error.ValidationError.t()
```

# `from_response`

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

Converts a raw HTTP error response into the appropriate error struct.

This function analyzes the HTTP response and creates a specific error struct
based on the status code and response body structure.

## Examples

    iex> Deputy.Error.from_response(%{status: 404, body: %{"message" => "Not found"}})
    %Deputy.Error.APIError{status: 404, code: nil, message: "Not found", details: %{}}

    iex> Deputy.Error.from_response(%{status: 429, body: %{"retry_after" => 30}})
    %Deputy.Error.RateLimitError{retry_after: 30, limit: nil, remaining: nil}

    iex> Deputy.Error.from_response(%{status: 500, body: "Server error"})
    %Deputy.Error.HTTPError{reason: "Server error", status: 500, body: "Server error"}

    iex> Deputy.Error.from_response(:timeout)
    %Deputy.Error.HTTPError{reason: :timeout, status: nil, body: nil}

---

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