Macro stakker::ret_failthru
source · macro_rules! ret_failthru { ($cx:expr, $msg:literal) => { ... }; ($cx:expr, $fmt:literal $(, $arg:expr)*) => { ... }; ($cx:expr, $error:expr) => { ... }; }
Expand description
Create a Ret
instance that passes through actor failure
ret_failthru!(cx, "format...", fmt-args...);
ret_failthru!(cx, "literal...");
ret_failthru!(cx, error);
This is designed to be used as a termination notifier for a child
actor in the actor!
or actor_new!
call. It receives an
Option<StopCause>
and terminates the current actor if the child
actor failed or lost connection. So this can be used in actors to
cascade failure upwards until it reaches an ancestor that can
handle it.
Note that this does not terminate this actor if the child actor
terminated successfully or if it was killed or dropped. Only
failure or lost connection is passed on as a failure. If the
child is never expected to terminate early, consider using
ret_fail!
instead, or writing your own termination handler if
the situation is more complex.
The arguments are treated as for fail!
, calling on to
Cx::fail
, Cx::fail_str
or Cx::fail_string
.
Note that errors are not normally chained in Stakker, i.e. the
failure wouldn’t normally contain details of the failures which
lead to that failure. The detailed history of a failure can be
analyzed by running with the logger feature enabled, and
looking at Open
and Close
events.