# `PolarExpress.Error`
[🔗](https://github.com/jeffhuen/polar_express/blob/main/lib/polar_express/error.ex#L1)

Polar API error.

All API errors are returned as `{:error, %PolarExpress.Error{}}` tuples.

## Error Types

  * `:api_error` - Generic API error
  * `:authentication_error` - Invalid API key (401)
  * `:forbidden_error` - Insufficient permissions (403)
  * `:validation_error` - Invalid parameters (400)
  * `:not_found_error` - Resource not found (404)
  * `:rate_limit_error` - Too many requests (429)
  * `:api_connection_error` - Network/connection failure
  * `:signature_verification_error` - Webhook signature mismatch

# `error_type`

```elixir
@type error_type() ::
  :api_error
  | :authentication_error
  | :forbidden_error
  | :validation_error
  | :not_found_error
  | :rate_limit_error
  | :api_connection_error
  | :signature_verification_error
```

# `t`

```elixir
@type t() :: %PolarExpress.Error{
  detail: String.t() | nil,
  error_code: String.t() | nil,
  http_body: String.t() | nil,
  http_headers: [{String.t(), String.t()}] | nil,
  http_status: integer() | nil,
  message: String.t() | nil,
  request_id: String.t() | nil,
  retry_after: number() | nil,
  type: error_type()
}
```

# `connection_error`

```elixir
@spec connection_error(String.t()) :: t()
```

Build a network/connection error.

# `from_response`

```elixir
@spec from_response(integer(), String.t(), [{String.t(), String.t()}]) :: t()
```

Build an error from an HTTP response.

# `retryable?`

```elixir
@spec retryable?(t()) :: boolean()
```

Returns true if this error is retryable.

# `signature_verification_error`

```elixir
@spec signature_verification_error(String.t()) :: t()
```

Build a webhook signature verification error.

---

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