From ba7ab29e5055f00185d908d5578e145698b508d2 Mon Sep 17 00:00:00 2001 From: Asten <0xasten@gmail.com> Date: Fri, 6 Dec 2024 23:41:30 +0800 Subject: [PATCH] refactor: improve error handling for transaction execution Enhances error messages in session.rs by adding descriptive context when transactions fail. This makes debugging easier by providing more detailed error information to JavaScript clients. --- packages/account-wasm/src/session.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/account-wasm/src/session.rs b/packages/account-wasm/src/session.rs index 64aab6d70..6dafe1c2a 100644 --- a/packages/account-wasm/src/session.rs +++ b/packages/account-wasm/src/session.rs @@ -143,7 +143,9 @@ impl CartridgeSessionAccount { .map(TryInto::try_into) .collect::, _>>()?; - let res = self.0.execute_v1(calls).send().await?; + let res = self.0.execute_v1(calls).send().await.map_err(|e| { + JsError::new(&format!("Execution failed: {:?}", e)) + })?; Ok(to_value(&res)?) }