ExDaytona.Error (ex_daytona v0.1.0)

Copy Markdown View Source

Normalized error for the SDK facade.

The generated openapi-generator client returns three different shapes for failures (spec-declared error models as {:ok, error_struct}, undeclared statuses as {:error, %Tesla.Env{}}, and transport failures as {:error, reason}). normalize/1 collapses all of them into {:error, %ExDaytona.Error{}} so facade callers match one shape:

  • status — HTTP status, or nil for transport failures
  • message — human-readable message
  • code — the API's error code string, when it sent one
  • details — the raw error payload (decoded map, model struct, or transport reason) for anything the other fields don't capture

Summary

Functions

Build an ExDaytona.Error from any failure shape the generated client produces.

Collapse a generated-client result into {:ok, value} or {:error, %ExDaytona.Error{}}.

Types

t()

@type t() :: %ExDaytona.Error{
  code: String.t() | nil,
  details: term(),
  message: String.t() | nil,
  status: non_neg_integer() | nil
}

Functions

from(error)

@spec from(term()) :: t()

Build an ExDaytona.Error from any failure shape the generated client produces.

normalize(arg)

@spec normalize(term()) :: {:ok, term()} | {:error, t()}

Collapse a generated-client result into {:ok, value} or {:error, %ExDaytona.Error{}}.

Success values (decoded models, lists, maps, and 2xx Tesla.Env passthroughs) are left untouched.