AshTypescript.Rpc.Error protocol (ash_typescript v0.11.4)
View SourceProtocol for extracting minimal information from exceptions for RPC responses.
Similar to AshGraphql.Error, this protocol transforms various error types into a standardized format with only the essential information needed by TypeScript clients.
Error Format
Each implementation should return a map with these fields:
:message- The full error message (may contain template variables like %{key}):short_message- A concise version of the message:type- A machine-readable error type (e.g., "invalid_changes", "not_found"):vars- A map of variables to interpolate into messages:fields- A list of affected field names (for field-level errors):path- The path to the error location in the data structure:details- An optional map with extra details
Example Implementation
defimpl AshTypescript.Rpc.Error, for: MyApp.CustomError do
def to_error(error) do
%{
message: error.message,
short_message: "Custom error occurred",
type: "custom_error",
vars: %{detail: error.detail},
fields: [],
path: error.path || []
}
end
end
Summary
Functions
Transforms an exception into a minimal error representation for RPC responses.
Types
@type t() :: term()
All the types that implement this protocol.
Functions
@spec to_error(Exception.t()) :: map()
Transforms an exception into a minimal error representation for RPC responses.