Added reply with error.
This commit is contained in:
@@ -54,9 +54,9 @@ impl Document {
|
||||
let name = msg.get_data("name").unwrap().to_string();
|
||||
match self.data.get(&name) {
|
||||
Some(_) => {
|
||||
let mut reply = msg.reply(MsgType::Error);
|
||||
reply.add_data("error_type", ErrorType::DocumentAlreadyExists);
|
||||
self.queue.send(reply).unwrap();
|
||||
self.queue
|
||||
.send(msg.reply_with_error(ErrorType::DocumentAlreadyExists))
|
||||
.unwrap();
|
||||
return;
|
||||
}
|
||||
None => {}
|
||||
@@ -64,9 +64,9 @@ impl Document {
|
||||
let doc: Value = match serde_json::from_str(&msg.get_data("doc").unwrap().to_string()) {
|
||||
Ok(value) => value,
|
||||
Err(_) => {
|
||||
let mut reply = msg.reply(MsgType::Error);
|
||||
reply.add_data("error_type", ErrorType::DocumentInvalidRequest);
|
||||
self.queue.send(reply).unwrap();
|
||||
self.queue
|
||||
.send(msg.reply_with_error(ErrorType::DocumentInvalidRequest))
|
||||
.unwrap();
|
||||
return;
|
||||
}
|
||||
};
|
||||
@@ -86,11 +86,7 @@ impl Document {
|
||||
holder.add_data("doc", data.clone());
|
||||
holder
|
||||
}
|
||||
None => {
|
||||
let mut holder = msg.reply(MsgType::Error);
|
||||
holder.add_data("error_type", ErrorType::DocumentNotFound);
|
||||
holder
|
||||
}
|
||||
None => msg.reply_with_error(ErrorType::DocumentNotFound),
|
||||
};
|
||||
self.queue.send(reply).unwrap();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user