# `ApifyClient.Error`
[🔗](https://github.com/social-growth-studio/apify-client-ex/blob/v1.0.0/lib/apify_client/error.ex#L1)

Error returned (or, from streams, raised) by every Apify API call.

Functions return `{:error, %ApifyClient.Error{}}`; lazy streams such as
`ApifyClient.Datasets.stream_items/2` raise it, since it is an exception.

For API errors, `details` contains:

  * `:status_code` - the HTTP status
  * `:error_type` - the API's error type, for example `"record-not-found"`,
    when the response has one
  * `:body` - the (decoded) response body

Network errors have the transport `:reason` in `details`.

# `error_type`

```elixir
@type error_type() ::
  :client_error
  | :server_error
  | :network_error
  | :rate_limit_error
  | :authentication_error
  | :authorization_error
  | :not_found_error
  | :validation_error
  | :conflict_error
  | :timeout_error
  | :stream_error
  | :file_error
  | :unknown_error
```

# `t`

```elixir
@type t() :: %ApifyClient.Error{
  __exception__: term(),
  details: map(),
  message: String.t(),
  type: error_type()
}
```

# `message`

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

Returns a human-readable string representation of the error.

# `new`

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

Creates a new error struct.

---

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