From d68e5edfa6a2c776083d753e3425b47065e130a2 Mon Sep 17 00:00:00 2001 From: mwtian <81660174+mwtian@users.noreply.github.com> Date: Wed, 5 Oct 2022 19:48:31 -0700 Subject: [PATCH] Format sub errors of `ExecutionDriverError` with `Display` instead of `Debug` (#5011) --- crates/sui-core/src/node_sync/node_state.rs | 26 +++++++++++++++++++++ crates/sui-types/src/error.rs | 4 ++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/crates/sui-core/src/node_sync/node_state.rs b/crates/sui-core/src/node_sync/node_state.rs index 50d0a5105a513..91f4d25e24758 100644 --- a/crates/sui-core/src/node_sync/node_state.rs +++ b/crates/sui-core/src/node_sync/node_state.rs @@ -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 : [ ] ] ]"); + } +} diff --git a/crates/sui-types/src/error.rs b/crates/sui-types/src/error.rs index 6302e62e30baa..d6006f3851cf7 100644 --- a/crates/sui-types/src/error.rs +++ b/crates/sui-types/src/error.rs @@ -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::>() + format!("[ {} ]", errors.iter().map(|e| ToString::to_string(&e)).collect::>().join("; ")), )] ExecutionDriverError { digest: TransactionDigest,