Poodle.Error (poodle v1.0.0)
View SourceError struct for the Poodle SDK.
Provides structured error information with context and debugging details.
Summary
Functions
Create a new DNS error.
Create a new forbidden error.
Create an error from HTTP response.
Create a new network error.
Create a new payment required error.
Create a new rate limit exceeded error.
Create a new server error.
Create a new SSL error.
Create a new timeout error.
Create a new unauthorized error.
Create a new unprocessable entity error.
Create a new validation error.
Types
@type error_type() ::
:validation_error
| :unauthorized
| :forbidden
| :payment_required
| :unprocessable_entity
| :rate_limit_exceeded
| :server_error
| :network_error
| :timeout
| :dns_error
| :ssl_error
@type t() :: %Poodle.Error{ details: map() | nil, message: String.t(), retry_after: integer() | nil, status_code: integer() | nil, type: error_type() }
Functions
Create a new DNS error.
Examples
iex> Poodle.Error.dns_error("DNS resolution failed", %{host: "api.example.com"})
%Poodle.Error{type: :dns_error, message: "DNS resolution failed", details: %{host: "api.example.com"}}
Create a new forbidden error.
Examples
iex> Poodle.Error.forbidden("Account suspended")
%Poodle.Error{type: :forbidden, message: "Account suspended"}
Create an error from HTTP response.
Examples
iex> Poodle.Error.from_response(401, %{"message" => "Invalid API key"})
%Poodle.Error{type: :unauthorized, message: "Invalid API key", status_code: 401}
Create a new network error.
Examples
iex> Poodle.Error.network_error("Connection failed")
%Poodle.Error{type: :network_error, message: "Connection failed"}
Create a new payment required error.
Examples
iex> Poodle.Error.payment_required("Subscription expired")
%Poodle.Error{type: :payment_required, message: "Subscription expired"}
Create a new rate limit exceeded error.
Examples
iex> Poodle.Error.rate_limit_exceeded("Rate limit exceeded", 30)
%Poodle.Error{type: :rate_limit_exceeded, message: "Rate limit exceeded", retry_after: 30}
Create a new server error.
Examples
iex> Poodle.Error.server_error("Internal server error", 500)
%Poodle.Error{type: :server_error, message: "Internal server error", status_code: 500}
Create a new SSL error.
Examples
iex> Poodle.Error.ssl_error("SSL certificate verification failed")
%Poodle.Error{type: :ssl_error, message: "SSL certificate verification failed"}
Create a new timeout error.
Examples
iex> Poodle.Error.timeout("Request timeout", %{timeout: 30000})
%Poodle.Error{type: :timeout, message: "Request timeout", details: %{timeout: 30000}}
Create a new unauthorized error.
Examples
iex> Poodle.Error.unauthorized("Invalid API key")
%Poodle.Error{type: :unauthorized, message: "Invalid API key"}
Create a new unprocessable entity error.
Examples
iex> Poodle.Error.unprocessable_entity("Invalid data format")
%Poodle.Error{type: :unprocessable_entity, message: "Invalid data format", status_code: 422}
Create a new validation error.
Examples
iex> Poodle.Error.validation_error("Invalid email address", %{field: "from"})
%Poodle.Error{type: :validation_error, message: "Invalid email address", details: %{field: "from"}}