AshDyan.Error exception (AshDyan v0.1.0)

Copy Markdown View Source

Error type raised/returned by AshDyan.

Errors are structured so callers can pattern-match and so validation errors name the offending field/function rather than just saying "invalid request".

Fields

  • :message — a human-readable description.
  • :field — the offending request field (e.g. :column, :filters, :limit), or nil for non-field errors.
  • :reason — a stable atom for programmatic matching. Common values: :not_a_resource, :not_analyzable, :unknown_type, :not_allowed, :too_many, :too_large, :unknown_attribute, :bad_type, :invalid_value, :no_primary_read_action, :unsupported_data_layer.

Example

case AshDyan.run(spec) do
  {:ok, result} -> result
  {:error, %AshDyan.Error{field: :limit, reason: :too_large}} ->
    # surface a friendly message to the caller
end

Summary

Types

t()

@type t() :: %AshDyan.Error{
  __exception__: true,
  field: atom() | nil,
  message: String.t(),
  reason: atom() | nil
}