Skip to content

Commit 5c50ce8

Browse files
Improve the developer experience of the linera-sdk and the solidity compiler. (#3655)
## Motivation There are a few ways to improve the developer experience of apps on Linera. ## Proposal The following is done: * Add the printing of the `Vec<u8>` that cannot be deserialized in `execute_operation` and `instantiate`. This is done in the same way as for `handle_query`. * Print the actual compilation error in `get_bytecode_path` if it fails. In both cases, the error message is built only if something goes wrong. ## Test Plan The CI. ## Release Plan Normal release schedule. ## Links None.
1 parent 7b4ddf7 commit 5c50ce8

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

linera-execution/src/test_utils/solidity.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ fn get_bytecode_path(path: &Path, file_name: &str, contract_name: &str) -> anyho
5959
let json_data: serde_json::Value = serde_json::from_str(&contents)?;
6060
let contracts = json_data
6161
.get("contracts")
62-
.context("failed to get contracts")?;
62+
.with_context(|| format!("failed to get contracts in json_data={}", json_data))?;
6363
let file_name_contract = contracts
6464
.get(file_name)
6565
.context("failed to get {file_name}")?;

linera-sdk/src/contract/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ macro_rules! contract {
4848
unsafe { &mut CONTRACT },
4949
move |contract| {
5050
let argument = $crate::serde_json::from_slice(&argument)
51-
.expect("Failed to deserialize instantiation argument");
51+
.unwrap_or_else(|_| panic!("Failed to deserialize instantiation argument {argument:?}"));
5252

5353
contract.instantiate(argument).blocking_wait()
5454
},
@@ -62,7 +62,7 @@ macro_rules! contract {
6262
move |contract| {
6363
let operation: <$contract as $crate::abi::ContractAbi>::Operation =
6464
$crate::bcs::from_bytes(&operation)
65-
.expect("Failed to deserialize operation");
65+
.unwrap_or_else(|_| panic!("Failed to deserialize operation {operation:?}"));
6666

6767
let response = contract.execute_operation(operation).blocking_wait();
6868

0 commit comments

Comments
 (0)