Skip to main content

codex_bail

Macro codex_bail 

Source
macro_rules! codex_bail {
    ($name:expr, $cause:expr $(, $key:expr => $val:expr)* $(,)?) => { ... };
}
Expand description

Macro for immediate exit from a function with a CodexError.

Use this macro to propagate an error when a failure condition is met. It automatically injects the caller’s location and accepts optional metadata for extended diagnostics.

§Examples

use cirious_codex_result::{codex_bail, codex_ok, Result};

fn find_user(id: u32) -> Result<String> {
    if id == 0 {
        codex_bail!("INVALID_ID", "User ID cannot be zero", "attempted" => "0");
    }
    codex_ok!("User".to_string().into())
}