A2UICore.Error exception (A2UICore v0.1.1)

Copy Markdown View Source

The single error struct used across the A2UI packages.

Categories classify errors for conformance matching and are drawn from the reference implementation's exception classes:

CategoryReference class
:parseA2uiParseError
:validationA2uiValidationError
:catalogA2uiCatalogError
:stateA2uiStateError
:integrityA2uiIntegrityError
:recursionA2uiRecursionError
:dataA2uiDataError
:expressionA2uiExpressionError
:rpcA2uiRpcError
:compilationA2uiCompilationError (agent side)

A2UICore.Error is usable both as a raised exception and inside {:error, error} tuples; both forms are equivalent and the harness decides which shape is used at the call site.

Summary

Functions

Builds a new A2UICore.Error with the given category and code.

Convenience raise helper — equivalent to raise A2UICore.Error, category:..., code:..., message:....

Types

category()

(since 0.1.0)
@type category() ::
  :parse
  | :validation
  | :catalog
  | :state
  | :integrity
  | :recursion
  | :data
  | :expression
  | :rpc
  | :compilation

detail()

(since 0.1.0)
@type detail() :: %{path: String.t() | nil, code: String.t(), message: String.t()}

t()

(since 0.1.0)
@type t() :: %A2UICore.Error{
  __exception__: term(),
  category: category(),
  code: String.t(),
  details: [A2UICore.Error.Detail.t()],
  function_call_id: String.t() | nil,
  message: String.t(),
  path: String.t() | nil,
  surface_id: String.t() | nil
}

Functions

new(category, code, message, opts \\ [])

(since 0.1.0)
@spec new(category(), String.t(), String.t(), keyword()) :: t()

Builds a new A2UICore.Error with the given category and code.

Options

  • :path — JSON pointer of the offending field.
  • :surface_id — the surface the error pertains to.
  • :function_call_id — relevant for v1.0 RPC failures.
  • :details — list of A2UICore.Error.Detail.t/0.

Examples

iex> err = A2UICore.Error.new(:validation, "VALIDATION_FAILED", "bad")
iex> {err.category, err.code}
{:validation, "VALIDATION_FAILED"}

raise!(category, code, message, opts \\ [])

(since 0.1.0)
@spec raise!(category(), String.t(), String.t(), keyword()) :: no_return()

Convenience raise helper — equivalent to raise A2UICore.Error, category:..., code:..., message:....