iron::itry! [] [src]

macro_rules! itry {
    ($result:expr) => (itry!($result, $crate::status::InternalServerError));

    ($result:expr, $modifier:expr) => (match $result {
        ::std::result::Result::Ok(val) => val,
        ::std::result::Result::Err(err) => return ::std::result::Result::Err(
            $crate::IronError::new(err, $modifier))
    })
}

Like try!(), but wrapping the error value in IronError. To be used in request handlers.

let f = itry!(fs::File::create("foo.txt"), status::BadRequest);
let f = itry!(fs::File::create("foo.txt"));  // Default modifier is status::InternalServerError