Skip to main content

set_error

Function set_error 

Source
pub fn set_error(
    req: &mut Msg,
    error_code: i32,
    dyn_error_code: DynErrorCode,
) -> bool
Expand description

Mark req as in-error with error_code (a libc errno-shaped value) and the matching dyn_error_code. The flag is set so the response path can synthesise an error reply on the next pass.

Returns true when the message transitions from healthy to error; subsequent calls are no-ops.

ยงExamples

use dynomite::msg::{request, DynErrorCode, Msg, MsgType};

let mut req = Msg::new(1, MsgType::ReqRedisGet, true);
assert!(request::set_error(&mut req, 13, DynErrorCode::PeerHostDown));
assert!(req.flags().is_error);
assert!(!request::set_error(&mut req, 13, DynErrorCode::PeerHostDown));