CampaignFlow.Client.Error (CampaignFlow Client v2.0.0)

View Source

Error handling for the Campaign Flow API client.

This module defines error types and provides helper functions for working with API errors.

Summary

Functions

Returns true if the error is an authentication error.

Converts an error to a human-readable string.

Creates a new error struct from various error formats.

Returns true if the error is a validation error.

Types

t()

@type t() :: %CampaignFlow.Client.Error{
  details: map() | nil,
  message: String.t(),
  status: integer() | nil,
  type: atom()
}

Functions

auth_error?(arg1)

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

Returns true if the error is an authentication error.

message(error)

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

Converts an error to a human-readable string.

new(error)

@spec new(atom() | tuple()) :: t()

Creates a new error struct from various error formats.

Examples

CampaignFlow.Client.Error.new(:unauthorized)
#=> %CampaignFlow.Client.Error{type: :unauthorized, message: "Unauthorized - authentication failed or token is invalid", status: 401}

CampaignFlow.Client.Error.new({:validation_error, %{"errors" => %{"name" => ["is required"]}}})
#=> %CampaignFlow.Client.Error{type: :validation_error, message: "Validation failed", details: %{"errors" => %{"name" => ["is required"]}}}

validation_error?(arg1)

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

Returns true if the error is a validation error.