Column.Error exception (Column v1.0.0)

Copy Markdown View Source

Structured error type returned by all Column API calls.

Error categories

  • :api_error — Column returned a 4xx/5xx response with an error body
  • :network_error — Transport-level failure (timeout, connection refused)
  • :decode_error — Response body could not be decoded as JSON
  • :validation_error — Local validation failed before making the request

Usage

case Column.BankAccounts.get("bacc_123") do
  {:ok, account} -> account
  {:error, %Column.Error{type: :api_error, status: 404}} -> handle_not_found()
  {:error, %Column.Error{type: :network_error}} -> handle_timeout()
  {:error, %Column.Error{} = err} -> handle_generic(err)
end

Summary

Functions

Build a JSON decode error.

Build from a network/transport error.

Build from a Column API error response body + HTTP status.

Build a local validation error.

Types

error_type()

@type error_type() :: :api_error | :network_error | :decode_error | :validation_error

t()

@type t() :: %Column.Error{
  __exception__: true,
  code: String.t() | nil,
  message: String.t(),
  raw: map() | nil,
  request_id: String.t() | nil,
  status: non_neg_integer() | nil,
  type: error_type()
}

Functions

decode(message)

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

Build a JSON decode error.

from_exception(exception)

@spec from_exception(Exception.t()) :: t()

Build from a network/transport error.

from_response(status, body, request_id \\ nil)

@spec from_response(non_neg_integer(), map(), String.t() | nil) :: t()

Build from a Column API error response body + HTTP status.

validation(message)

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

Build a local validation error.