Sprites.Error.APIError exception (Sprites v0.1.0)

View Source

Raised when the API returns an error response.

Provides detailed information about rate limits and other API errors.

Summary

Functions

Returns the number of seconds to wait before retrying. Prefers the JSON field, falling back to the header value.

Returns true if this is a concurrent sprite limit error

Returns true if this is a sprite creation rate limit error

Returns true if this is a 429 rate limit error

Types

t()

@type t() :: %Sprites.Error.APIError{
  __exception__: term(),
  body: String.t() | nil,
  current_count: integer() | nil,
  error_code: String.t() | nil,
  limit: integer() | nil,
  message: String.t() | nil,
  rate_limit_limit: integer() | nil,
  rate_limit_remaining: integer() | nil,
  rate_limit_reset: integer() | nil,
  retry_after_header: integer() | nil,
  retry_after_seconds: integer() | nil,
  status: integer() | nil,
  upgrade_available: boolean() | nil,
  upgrade_url: String.t() | nil,
  window_seconds: integer() | nil
}

Functions

get_retry_after_seconds(api_error)

@spec get_retry_after_seconds(t()) :: integer() | nil

Returns the number of seconds to wait before retrying. Prefers the JSON field, falling back to the header value.

is_concurrent_limit_exceeded?(api_error)

@spec is_concurrent_limit_exceeded?(t()) :: boolean()

Returns true if this is a concurrent sprite limit error

is_creation_rate_limited?(api_error)

@spec is_creation_rate_limited?(t()) :: boolean()

Returns true if this is a sprite creation rate limit error

is_rate_limit_error?(api_error)

@spec is_rate_limit_error?(t()) :: boolean()

Returns true if this is a 429 rate limit error