Skip to main content

op_error

Macro op_error 

Source
macro_rules! op_error {
    ($ctx:expr, $($arg:tt)*) => { ... };
}
Expand description

Builds an OperationError::Custom from format arguments, tagged with the operation name taken from a Context.

Thin wrapper over Context::error that lets custom operations use format!-style syntax without the format! call. The first argument is the context ($ctx); the rest are passed verbatim to format!.

use panopticon_core::extend::*;

fn execute(ctx: &mut Context) -> Result<(), OperationError> {
    let key: i64 = 42;
    Err(op_error!(ctx, "key {} out of range", key))
}