Skip to content

Commit

Permalink
Format sub errors of ExecutionDriverError with Display instead of…
Browse files Browse the repository at this point in the history
… `Debug` (MystenLabs#5011)
  • Loading branch information
mwtian authored Oct 6, 2022
1 parent 41e7471 commit d68e5ed
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
26 changes: 26 additions & 0 deletions crates/sui-core/src/node_sync/node_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1085,3 +1085,29 @@ impl NodeSyncHandle {
Ok(Self::map_rx(rx))
}
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn test_display_execution_driver_error() {
let digest = TransactionDigest::new([11u8; 32]);
let err0 = SuiError::ExecutionDriverError {
digest,
msg: "test 0".into(),
errors: Vec::new(),
};
let err1 = SuiError::ExecutionDriverError {
digest,
msg: "test 1".into(),
errors: vec![err0],
};
let err2 = SuiError::ExecutionDriverError {
digest,
msg: "test 2".into(),
errors: vec![err1],
};
assert_eq!(format!("{}", err2), "ExecutionDriver error for CwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCws=: test 2 - Caused by : [ ExecutionDriver error for CwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCws=: test 1 - Caused by : [ ExecutionDriver error for CwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCws=: test 0 - Caused by : [ ] ] ]");
}
}
4 changes: 2 additions & 2 deletions crates/sui-types/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,10 @@ pub enum SuiError {
#[error("Checkpointing error: {}", error)]
CheckpointingError { error: String },
#[error(
"ExecutionDriver error for {:?}: {} - Caused by : {:#?}",
"ExecutionDriver error for {:?}: {} - Caused by : {}",
digest,
msg,
errors.iter().map(|e| ToString::to_string(&e)).collect::<Vec<String>>()
format!("[ {} ]", errors.iter().map(|e| ToString::to_string(&e)).collect::<Vec<String>>().join("; ")),
)]
ExecutionDriverError {
digest: TransactionDigest,
Expand Down

0 comments on commit d68e5ed

Please sign in to comment.