AshTypescript.Rpc.DefaultErrorHandler (ash_typescript v0.17.2)

Copy Markdown View Source

Default error handler for RPC operations.

This handler returns errors as-is without any transformation. Variable interpolation is left to the client for better flexibility.

This module is called as the last step in the error processing pipeline.

Summary

Functions

Default error handler that returns errors as-is.

Functions

handle_error(error, context)

@spec handle_error(map(), map()) :: map()

Default error handler that returns errors as-is.

Previously this handler would interpolate variables into messages, but now we let the client handle that for better flexibility.

The error is returned with the message template and vars separate, allowing the client to handle interpolation as needed.

Examples

iex> error = %{
...>   message: "Field %{field} is required",
...>   short_message: "Required field",
...>   vars: %{field: "email"},
...>   code: "required",
...>   fields: ["email"]
...> }
iex> handle_error(error, %{})
%{
  message: "Field %{field} is required",
  short_message: "Required field",
  vars: %{field: "email"},
  code: "required",
  fields: ["email"]
}