View Source AshJsonApi.ToJsonApiError protocol (ash_json_api v1.4.6)
A protocol for turning an Ash exception into an AshJsonApi.Error
To use, implement the protocol for a builtin Ash exception type or for your own custom Ash exception.
Example
defmodule NotAvailable do
use Ash.Error.Exception
use Splode.Error,
fields: [],
class: :invalid
defimpl AshJsonApi.ToJsonApiError do
def to_json_api_error(error) do
%AshJsonApi.Error{
id: Ash.UUID.generate(),
status_code: 409,
code: "not_available",
title: "not_available",
detail: "Not available"
}
end
end
end
Summary
Types
@type t() :: term()
All the types that implement this protocol.
Functions
@spec to_json_api_error(term()) :: AshJsonApi.Error.t() | [AshJsonApi.Error.t()]