Macro io_error::err [] [src]

macro_rules! err {
    ($kind:ident, $desc:expr, $($rest:tt)*) => { ... };
    ($kind:ident, $desc:expr) => { ... };
}

Create an I/O error.

This constructs a value of type std::io::Error defined by the given parameter.

The first argument defines the kind (std::io::ErrorKind) of the error. There is no need for importing the type, as it is already prefixed with the enum.

The second argument is the description of the error, given in the form of a string literal.

The rest arguments are the usual formatting syntax (like println!()) representing the Display implementation of the error. If none, it will simply use the second argument (the description).

Example

#[macro_use]
extern crate io_error;

let x = 42 + 3;
let error = err!(NotFound, "my error description", "this is an error, x is {}", x);
let error2 = err!(InvalidData, "my second error description");