Jido. Flow. Error
(Jido Action v3.0.0-beta.12)
View Source
Defines and normalizes errors owned by Jido Flows.
Flow errors cover authoring data, compilation, native Runic coordination,
and Flow execution state. An Action failure inside a Flow keeps its original
Jido.Action.Error type. This module can merge those Action errors when one
Flow operation has more than one failure.
Summary
Functions
Creates a Flow execution failure.
Creates one failure for a Flow operation with failed Runic runnables.
Creates an internal Flow error.
Creates an invalid Flow execution input or state error.
Returns whether a Flow or Action error is retryable.
Creates a Flow timeout error.
Converts a Flow or Action error into its public map.
Traverses errors, calling fun for each leaf error, and returns a nested
map of results grouped by each error's path.
Raises an error if the result is an error, otherwise returns the result
Creates an invalid Flow definition error.
Types
@type class() :: %{ :__struct__ => class_module(), :__exception__ => true, :errors => [t()], :class => error_class(), :bread_crumbs => [String.t()], :vars => Keyword.t(), :stacktrace => Splode.Stacktrace.t() | nil, :context => map(), optional(atom()) => any() }
@type class_module() ::
Jido.Flow.Error.Internal
| Jido.Flow.Error.Execution
| Jido.Flow.Error.Invalid
| Splode.Error.Unknown
@type error_class() :: :internal | :execution | :invalid | :unknown
@type error_map() :: Jido.Action.Error.error_map()
@type runnable_failure() :: %{ node: term(), runnable_id: Runic.Identity.t() | integer(), error: Exception.t() }
@type t() :: %{ :__struct__ => module(), :__exception__ => true, :class => error_class(), :bread_crumbs => [String.t()], :vars => Keyword.t(), :stacktrace => Splode.Stacktrace.t() | nil, :context => map(), optional(atom()) => any() }
Functions
@spec execution_error(String.t(), details_input()) :: Jido.Flow.Error.ExecutionFailureError.t()
Creates a Flow execution failure.
@spec flow_failure(String.t(), [runnable_failure()]) :: Jido.Flow.Error.ExecutionFailureError.t()
Creates one failure for a Flow operation with failed Runic runnables.
@spec internal_error(String.t(), details_input()) :: Jido.Flow.Error.InternalError.t()
Creates an internal Flow error.
@spec invalid_execution_error(String.t(), details_input()) :: Jido.Flow.Error.InvalidExecutionError.t()
Creates an invalid Flow execution input or state error.
Returns whether a Flow or Action error is retryable.
@spec timeout_error(String.t(), details_input()) :: Jido.Flow.Error.TimeoutError.t()
Creates a Flow timeout error.
Converts a Flow or Action error into its public map.
Detail values stay unchanged. A caller that sends the map through JSON or another transport must convert its own detail values for that transport. Nested Flow and Action errors become their public maps.
Traverses errors, calling fun for each leaf error, and returns a nested
map of results grouped by each error's path.
See Splode.traverse_errors/2 for full documentation.
Example
iex> Elixir.Jido.Flow.Error.traverse_errors(error, fn error ->
...> Exception.message(error)
...> end)
%{name: ["name is required"]}
Raises an error if the result is an error, otherwise returns the result
Alternatively, you can use the defsplode macro, which does this automatically.
Options
:error_opts- Options to pass toto_error/2when converting the returned error:unknown_error_opts- Options to pass to the unknown error if the function returns only:error. not necessary if your function always returns{:error, error}.
Examples
def function(arg) do
case do_something(arg) do
:success -> :ok
{:success, result} -> {:ok, result}
{:error, error} -> {:error, error}
endend
def function!(arg) do
YourErrors.unwrap!(function(arg))end
@spec validation_error(String.t(), details_input()) :: Jido.Flow.Error.InvalidDefinitionError.t()
Creates an invalid Flow definition error.