Rulestead.Error exception (rulestead v0.1.2)

Copy Markdown View Source

Stable public error envelope for all non-bang and bang APIs.

Rulestead returns this struct in {:error, error} tuples and raises the same struct from bang variants. Typed helper modules such as Rulestead.StoreError construct this envelope instead of introducing competing public error structs.

Summary

Types

Top-level error family used to group stable leaf error types.

t()

Closed Phase 2 leaf error atoms.

Functions

Returns the stable top-level error domains.

Returns the closed Phase 2 leaf error atoms.

Builds a new normalized error struct.

Normalizes a term into a Rulestead.Error.

Types

detail()

@type detail() :: %{optional(detail_key()) => detail_value()}

detail_key()

@type detail_key() :: atom() | String.t()

detail_value()

@type detail_value() :: nil | boolean() | integer() | float() | atom() | String.t()

domain()

@type domain() :: :evaluation | :ruleset | :kill_switch | :config | :store | :auth

Top-level error family used to group stable leaf error types.

metadata()

@type metadata() :: %{optional(metadata_key()) => metadata_scalar()}

metadata_key()

@type metadata_key() :: atom() | String.t()

metadata_scalar()

@type metadata_scalar() :: nil | boolean() | integer() | float() | atom() | String.t()

t()

@type t() :: %Rulestead.Error{
  __exception__: true,
  cause: term(),
  details: [detail()],
  domain: domain(),
  message: String.t(),
  metadata: metadata(),
  plug_status: nil | pos_integer(),
  type: type()
}

type()

@type type() ::
  :flag_not_found
  | :environment_not_found
  | :snapshot_not_found
  | :ruleset_not_found
  | :missing_targeting_key
  | :repo_not_configured
  | :repo_ambiguous
  | :store_not_configured
  | :store_adapter_invalid
  | :store_unavailable
  | :invalid_command
  | :invalid_ruleset
  | :variant_weights_invalid
  | :invalid_value_projection
  | :malformed_runtime_data
  | :flag_archived
  | :unauthorized
  | :kill_switch_active
  | :not_implemented

Closed Phase 2 leaf error atoms.

Downstream phases should extend this list deliberately when they add new public failure modes rather than returning broad atoms such as :invalid or :not_found.

Functions

domains()

@spec domains() :: [domain()]

Returns the stable top-level error domains.

leaf_types()

@spec leaf_types() :: [type()]

Returns the closed Phase 2 leaf error atoms.

new(attrs)

@spec new(keyword() | map()) :: t()

Builds a new normalized error struct.

normalize(error)

@spec normalize(t() | keyword() | map()) :: t()

Normalizes a term into a Rulestead.Error.