AmpSdk.Error exception (AmpSdk v0.4.0)

Copy Markdown View Source

Unified error envelope for SDK operations.

All public tuple-based APIs return {:error, %AmpSdk.Error{}} for consistent pattern matching.

Summary

Types

kind()

@type kind() ::
  :cli_not_found
  | :command_failed
  | :command_timeout
  | :command_execution_failed
  | :stream_start_failed
  | :transport_error
  | :parse_error
  | :invalid_message
  | :invalid_configuration
  | :execution_failed
  | :no_result
  | :task_timeout
  | :task_exit
  | :unknown

normalize_opt()

@type normalize_opt() ::
  {:kind, kind()}
  | {:message, String.t()}
  | {:cause, term()}
  | {:details, String.t() | nil}
  | {:context, map() | keyword() | nil}
  | {:exit_code, integer() | nil}

t()

@type t() :: %AmpSdk.Error{
  __exception__: true,
  cause: term(),
  context: map(),
  details: String.t() | nil,
  exit_code: integer() | nil,
  kind: kind(),
  message: String.t()
}

Functions

new(kind, message, opts \\ [])

@spec new(kind(), String.t(), [normalize_opt()]) :: t()

normalize(reason, opts \\ [])

@spec normalize(term(), [normalize_opt()]) :: t()