Skip to main content

fail_point_err

Macro fail_point_err 

Source
macro_rules! fail_point_err {
    ($name:expr, $map:expr) => { ... };
    ($scope:expr, $name:expr, $map:expr) => { ... };
}
Expand description

Inject a fail point that can abort the enclosing function with an error.

$map receives the detail string armed with FailAction::Fail and returns the error value to propagate, so each crate injects its own error type without the framework knowing about it:

ⓘ
fail_point_err!("wal::flush_out_of_space", |_| WalError::OutOfSpace {
    context: "WAL segment append (failpoint)",
});
fail_point_err!(FailScope::Node(node_id), "cut_floor::before_persist", |detail| {
    Error::Internal { detail }
});

Does nothing at runtime without the failpoints feature.