Show code and domain in bsonc error debug output

pull/4/head
Thijs Cadier 9 years ago
parent 72cb5be78f
commit 74c38fe32a

@ -147,6 +147,6 @@ mod tests {
assert!(bsonc_result.is_err());
let error_message = format!("{:?}", bsonc_result.err().unwrap());
assert!(error_message.starts_with("MongoError (BsoncError: parse error: premature EOF"));
assert!(error_message.starts_with("MongoError (BsoncError: Client/StreamInvalidType - parse error: premature EOF"));
}
}

@ -226,7 +226,13 @@ impl BsoncError {
impl fmt::Debug for BsoncError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "BsoncError: {}", &self.get_message())
write!(
f,
"BsoncError: {:?}/{:?} - {}",
&self.domain(),
&self.code(),
&self.get_message()
)
}
}

@ -15,7 +15,7 @@ fn test_execute_error() {
assert!(result.is_err());
let error_message = format!("{:?}", result.err().unwrap());
assert_eq!(error_message, "MongoError (BsoncError: Cannot do an empty bulk write)");
assert_eq!(error_message, "MongoError (BsoncError: Command/CommandInvalidArg - Cannot do an empty bulk write)");
}
#[test]

@ -133,7 +133,7 @@ fn test_insert_failure() {
let result = collection.insert(&document, None);
assert!(result.is_err());
assert_eq!(
"MongoError (BsoncError: Failed to connect to target host: localhost:27018)",
"MongoError (BsoncError: Stream/StreamConnect - Failed to connect to target host: localhost:27018)",
format!("{:?}", result.err().unwrap())
);
}

@ -52,7 +52,7 @@ fn test_tailing_cursor() {
let failing_result = failing_cursor.into_iter().next().unwrap();
assert!(failing_result.is_err());
assert_eq!(
"MongoError (BsoncError: Unable to execute query: error processing query: ns=rust_test.not_capped limit=0 skip=0\nTree: $and\nSort: {}\nProj: {}\n tailable cursor requested on non capped collection)",
"MongoError (BsoncError: Query/Unknown - Unable to execute query: error processing query: ns=rust_test.not_capped limit=0 skip=0\nTree: $and\nSort: {}\nProj: {}\n tailable cursor requested on non capped collection)",
format!("{:?}", failing_result.err().unwrap())
);

Loading…
Cancel
Save