Made MTTError a proper Error structure.
Some checks failed
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 1s
Some checks failed
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 1s
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
use crate::{
|
||||
action::{CalcValue, MsgAction, Operand, Query},
|
||||
document::field::{Field, FieldType},
|
||||
mtterror::MTTError,
|
||||
mtterror::{ErrorID, MTTError},
|
||||
name::{NameType, Names},
|
||||
queue::data_director::{Include, Path, Route},
|
||||
};
|
||||
@@ -195,15 +195,15 @@ mod messages {
|
||||
let name = Name::english("testing");
|
||||
let msg = Message::new(name.clone(), Query::new(name.clone()));
|
||||
let err_msg = Uuid::new_v4().to_string();
|
||||
let result = msg.response(MTTError::DocumentNotFound(err_msg.clone()));
|
||||
let result = msg.response(MTTError::new(NameType::None, ErrorID::DocumentNotFound));
|
||||
assert_eq!(result.get_message_id(), msg.get_message_id());
|
||||
match &result.document_id {
|
||||
NameType::Name(data) => assert_eq!(data, &name),
|
||||
_ => unreachable!("should have been a name"),
|
||||
}
|
||||
match result.get_action() {
|
||||
MsgAction::Error(data) => match data {
|
||||
MTTError::DocumentNotFound(txt) => assert_eq!(txt, &err_msg),
|
||||
MsgAction::Error(data) => match data.error_id() {
|
||||
ErrorID::DocumentNotFound => {}
|
||||
_ => unreachable!("got {:?}, should have received not found", data),
|
||||
},
|
||||
_ => unreachable!("should have been a reply"),
|
||||
@@ -215,7 +215,7 @@ mod messages {
|
||||
let doc_id = Uuid::new_v4();
|
||||
let msg = Message::new(doc_id.clone(), Query::new(doc_id.clone()));
|
||||
let data = Uuid::new_v4().to_string();
|
||||
let result1 = msg.response(MTTError::DocumentNotFound(data.clone()));
|
||||
let result1 = msg.response(MTTError::new(NameType::None, ErrorID::DocumentNotFound));
|
||||
let result2 = msg.response(Reply::new());
|
||||
assert_eq!(result1.get_message_id(), msg.get_message_id());
|
||||
assert_eq!(result2.get_message_id(), msg.get_message_id());
|
||||
@@ -223,8 +223,8 @@ mod messages {
|
||||
assert_eq!(result2.document_id, msg.document_id);
|
||||
let action1 = result1.get_action();
|
||||
match action1 {
|
||||
MsgAction::Error(err) => match err {
|
||||
MTTError::DocumentNotFound(output) => assert_eq!(output, &data),
|
||||
MsgAction::Error(err) => match err.error_id() {
|
||||
ErrorID::DocumentNotFound => {}
|
||||
_ => unreachable!("got {:?}: should have received document not found", err),
|
||||
},
|
||||
_ => unreachable!("got {:?}: should have received error", action1),
|
||||
@@ -466,7 +466,7 @@ impl Record {
|
||||
};
|
||||
match self.data.get(&id) {
|
||||
Some(data) => Ok(data.clone()),
|
||||
None => Err(MTTError::FieldMissingData),
|
||||
None => Err(MTTError::new(NameType::None, ErrorID::FieldMissingData)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user