diff --git a/e2e/tests-dfx/call.bash b/e2e/tests-dfx/call.bash index 53cba42ff7..d41042bec0 100644 --- a/e2e/tests-dfx/call.bash +++ b/e2e/tests-dfx/call.bash @@ -318,7 +318,7 @@ function impersonate_sender() { # test management canister call failure (setting memory allocation to a low value) assert_command_fail dfx canister update-settings hello_backend --memory-allocation 1 --impersonate "${IDENTITY_PRINCIPAL}" - assert_contains "Management canister call failed: IC0402: Canister was given 1 B memory allocation but at least" + assert_contains "Canister was given 1 B memory allocation but at least" # canister status fails because the default identity does not control the canister anymore assert_command_fail dfx canister status hello_backend @@ -334,22 +334,22 @@ function impersonate_sender() { # test management canister call submission failure assert_command_fail dfx canister status hello_backend --impersonate "${IDENTITY_PRINCIPAL}" - assert_contains "Failed to submit management canister call: IC0207: Canister $CANISTER_ID is out of cycles" + assert_contains "Failed to submit management canister call: Canister $CANISTER_ID is out of cycles" # test update call submission failure assert_command_fail dfx canister call aaaaa-aa canister_status "(record { canister_id=principal\"$CANISTER_ID\" })" --update --impersonate "${IDENTITY_PRINCIPAL}" - assert_contains "Failed to submit canister call: IC0207: Canister $CANISTER_ID is out of cycles" + assert_contains "Failed to submit canister call: Canister $CANISTER_ID is out of cycles" # test async call submission failure assert_command_fail dfx canister call aaaaa-aa canister_status "(record { canister_id=principal\"$CANISTER_ID\" })" --async --impersonate "${IDENTITY_PRINCIPAL}" - assert_contains "Failed to submit canister call: IC0207: Canister $CANISTER_ID is out of cycles" + assert_contains "Failed to submit canister call: Canister $CANISTER_ID is out of cycles" # unfreeze the canister assert_command dfx canister update-settings hello_backend --freezing-threshold 0 --impersonate "${IDENTITY_PRINCIPAL}" # test update call failure assert_command_fail dfx canister call aaaaa-aa delete_canister "(record { canister_id=principal\"$CANISTER_ID\" })" --update --impersonate "${IDENTITY_PRINCIPAL}" - assert_contains "Canister call failed: IC0510: Canister $CANISTER_ID must be stopped before it is deleted." + assert_contains "Canister call failed: Canister $CANISTER_ID must be stopped before it is deleted." # test update call assert_command dfx canister call aaaaa-aa start_canister "(record { canister_id=principal\"$CANISTER_ID\" })" --update --impersonate "${IDENTITY_PRINCIPAL}" @@ -361,7 +361,7 @@ function impersonate_sender() { # test query call failure assert_command_fail dfx canister call aaaaa-aa fetch_canister_logs "(record { canister_id=principal\"$CANISTER_ID\" })" --query --impersonate "$CANISTER_ID" - assert_contains "Failed to perform query call: IC0406: Caller $CANISTER_ID is not allowed to query ic00 method fetch_canister_logs" + assert_contains "Failed to perform query call: Caller $CANISTER_ID is not allowed to query ic00 method fetch_canister_logs" # test query call assert_command dfx canister call aaaaa-aa fetch_canister_logs "(record { canister_id=principal\"$CANISTER_ID\" })" --query --impersonate "${IDENTITY_PRINCIPAL}" diff --git a/src/dfx/src/commands/canister/call.rs b/src/dfx/src/commands/canister/call.rs index 7d432f0300..1e69f2d84f 100644 --- a/src/dfx/src/commands/canister/call.rs +++ b/src/dfx/src/commands/canister/call.rs @@ -366,7 +366,13 @@ To figure out the id of your wallet, run 'dfx identity get-wallet (--network ic) arg_value, ) .await - .map_err(|err| anyhow!("Failed to perform query call: {}", err))? + .map_err(|err| { + anyhow!( + "Failed to perform query call: {} ({})", + err.reject_message, + err.error_code + ) + })? } else { bail!("Impersonating sender is only supported for a local PocketIC instance.") } @@ -411,7 +417,13 @@ To figure out the id of your wallet, run 'dfx identity get-wallet (--network ic) arg_value, ) .await - .map_err(|err| anyhow!("Failed to submit canister call: {}", err))? + .map_err(|err| { + anyhow!( + "Failed to submit canister call: {} ({})", + err.reject_message, + err.error_code + ) + })? .message_id; CallResponse::Poll(RequestId::new(msg_id.as_slice().try_into().unwrap())) } else { @@ -460,11 +472,20 @@ To figure out the id of your wallet, run 'dfx identity get-wallet (--network ic) arg_value, ) .await - .map_err(|err| anyhow!("Failed to submit canister call: {}", err))?; - pocketic - .await_call_no_ticks(msg_id) - .await - .map_err(|err| anyhow!("Canister call failed: {}", err))? + .map_err(|err| { + anyhow!( + "Failed to submit canister call: {} ({})", + err.reject_message, + err.error_code + ) + })?; + pocketic.await_call_no_ticks(msg_id).await.map_err(|err| { + anyhow!( + "Canister call failed: {} ({})", + err.reject_message, + err.error_code + ) + })? } else { bail!("Impersonating sender is only supported for a local PocketIC instance.") } diff --git a/src/dfx/src/lib/operations/canister/mod.rs b/src/dfx/src/lib/operations/canister/mod.rs index e4d8528f2f..ef06f9974a 100644 --- a/src/dfx/src/lib/operations/canister/mod.rs +++ b/src/dfx/src/lib/operations/canister/mod.rs @@ -75,11 +75,20 @@ where encode_args((arg,)).unwrap(), ) .await - .map_err(|err| anyhow!("Failed to submit management canister call: {}", err))?; - let data = pocketic - .await_call_no_ticks(msg_id) - .await - .map_err(|err| anyhow!("Management canister call failed: {}", err))?; + .map_err(|err| { + anyhow!( + "Failed to submit management canister call: {} ({})", + err.reject_message, + err.error_code + ) + })?; + let data = pocketic.await_call_no_ticks(msg_id).await.map_err(|err| { + anyhow!( + "Management canister call failed: {} ({})", + err.reject_message, + err.error_code + ) + })?; decode_args(&data).context("Could not decode management canister response.")? } else { @@ -146,7 +155,11 @@ where ) .await .map_err(|err| { - anyhow!("Failed to perform management canister query call: {}", err) + anyhow!( + "Failed to perform management canister query call: {} ({})", + err.reject_message, + err.error_code + ) })?; decode_args(&data) .context("Failed to decode management canister query call response.")?