[][src]Macro witcher::bail

macro_rules! bail {
    ($msg:expr) => { ... };
    ($fmt:expr, $($arg:tt)*) => { ... };
}

Bail early from a function with an Error.

bail! just provides an implementation of the common error handling practice of allowing a user to return immediately with an error. Using bail!("oh no!") is the same thing as if you were to use return Error::new("oh no!") or return Err(Error::raw("oh no!").

It also provides a variation to allow for format!() type formatting.

Examples

bail!("oh no!");
bail!("foo: {}", "oh no!");