Miosa.Error exception (Miosa v1.0.1)

Copy Markdown View Source

Exception raised for MIOSA API errors.

Covers both HTTP-level errors (4xx, 5xx) and client-level errors (network failures, JSON decode errors, invalid configuration).

Fields

  • :message — Human-readable error description.
  • :status — HTTP status code (integer), or nil for non-HTTP errors.
  • :code — Machine-readable error code string from the API (e.g. "INSUFFICIENT_CREDITS"), or nil.
  • :body — Raw response body map, when available.

Examples

iex> raise Miosa.Error, message: "Not found", status: 404, code: "NOT_FOUND"
** (Miosa.Error) [404] NOT_FOUND: Not found

Summary

Functions

Builds a Miosa.Error for non-HTTP failures (network errors, decode errors).

Types

t()

@type t() :: %Miosa.Error{
  __exception__: true,
  body: map() | nil,
  code: String.t() | nil,
  message: String.t(),
  status: pos_integer() | nil
}

Functions

from_exception(exception)

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

Builds a Miosa.Error for non-HTTP failures (network errors, decode errors).

from_response(response)

@spec from_response(Req.Response.t()) :: t()

Builds a Miosa.Error from a Req.Response struct.

Parses the JSON body for "error" and "code" keys following the MIOSA API error envelope format.