AshIntrospection.Rpc.ErrorBuilder (AshIntrospection v0.4.0)

Copy Markdown View Source

Comprehensive error handling and message generation for the RPC pipeline.

Provides clear, actionable error messages for all failure modes with detailed context for debugging and client consumption.

This is a shared module used by both AshTypescript and AshKotlinMultiplatform. Language-specific behavior is configured via the config parameter.

Summary

Functions

Builds a detailed error response from various error types.

Types

config()

@type config() :: %{
  optional(:output_field_formatter) => atom(),
  optional(:field_formatter_module) => module()
}

Functions

build_error_response(error, config \\ %{})

@spec build_error_response(term(), config()) :: map() | [map()]

Builds a detailed error response from various error types.

Converts internal error tuples into structured error responses with clear messages and debugging context.

For Ash framework errors, uses the Error protocol for standardized extraction.

Returns either a single error map or a list of error maps (for Ash errors with multiple sub-errors).

Parameters

  • error - The error to build a response for
  • config - Language-specific configuration with:
    • :output_field_formatter - The formatter to use for field names (default: :camel_case)
    • :field_formatter_module - The module to use for field formatting (default: AshIntrospection.FieldFormatter)