Formats an error map for client consumption.
Error maps are templates: message, short_message and the strings under
details carry %{name} placeholders, while vars (and details) carry the
values. Interpolation is deliberately left to the client so messages can be
localized or reworded.
That makes key formatting and placeholder rewriting inseparable. Formatting
only the dictionary keys would break interpolation — a %{action_name}
placeholder cannot be resolved against a vars entry that arrived as
actionName — so this module renames both together.
Values inside vars are data, not templates, and are left alone.
Summary
Functions
Formats every key in error with formatter, rewriting %{name}
placeholders to match the renamed dictionary keys.
Functions
Formats every key in error with formatter, rewriting %{name}
placeholders to match the renamed dictionary keys.
Examples
iex> AshTypescript.ErrorFormatter.format(
...> %{message: "RPC action %{action_name} not found", vars: %{action_name: "foo"}},
...> :camel_case
...> )
%{"message" => "RPC action %{actionName} not found", "vars" => %{"actionName" => "foo"}}
iex> AshTypescript.ErrorFormatter.format(%{message: "is required"}, :camel_case)
%{"message" => "is required"}