AshTypescript.Rpc.Errors (ash_typescript v0.17.2)

Copy Markdown View Source

Central error processing module for RPC operations.

Handles error transformation, unwrapping, and formatting for TypeScript clients. Uses the AshTypescript.Rpc.Error protocol to extract minimal information from exceptions.

Summary

Functions

Transforms errors into standardized RPC error responses.

Unwraps nested error structures from Ash error classes.

Functions

to_errors(errors, domain \\ nil, resource \\ nil, action \\ nil, context \\ %{})

@spec to_errors(term(), atom() | nil, atom() | nil, atom() | nil, map()) :: [map()]

Transforms errors into standardized RPC error responses.

Processes errors through the following pipeline:

  1. Convert to Ash error class using Ash.Error.to_error_class
  2. Unwrap nested error structures
  3. Transform via Error protocol
  4. Apply resource-level error handler (if configured)
  5. Apply domain-level error handler (if configured)
  6. Interpolate variables into messages

unwrap_errors(errors)

@spec unwrap_errors(term()) :: [term()]

Unwraps nested error structures from Ash error classes.