Moss. Error exception
(moss v1.8.0)
Copy Markdown
The reason in every {:error, reason} this SDK returns.
code is an atom a caller can match on: :invalid_argument, :not_found,
:unauthorized, :network, :deserialization, :model_unavailable or
:internal. message is fixed text for each kind of failure and carries no
URLs, file paths or index names. detail holds the native core's error text,
for logs and support rather than a stable contract, and is nil when there is none.
Moss.Error is an exception, so raise reason works, and it implements
String.Chars, so "#{reason}" renders the message.
case Moss.Client.load_index(client, "docs") do
{:ok, info} -> info
{:error, %Moss.Error{code: :not_found}} -> nil
end