Skip to content

Commit

Permalink
chore: make payload exceeded error message more readable
Browse files Browse the repository at this point in the history
  • Loading branch information
ielashi committed Jul 19, 2023
1 parent 8475802 commit 26fe0dd
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions rs/system_api/src/request_in_prep.rs
Expand Up @@ -67,8 +67,8 @@ impl RequestInPrep {
let max_size_local_subnet = max_size_remote_subnet * multiplier_max_size_local_subnet;
if method_name_len as u64 > max_size_local_subnet.get() {
return Err(HypervisorError::ContractViolation(format!(
"RequestInPrep: size of method_name {} exceeded the allowed limit local-subnet {} remote-subnet {}",
callee_size, max_size_local_subnet, max_size_remote_subnet
"Size of method_name {} exceeds the allowed limit local-subnet {}",
callee_size, max_size_local_subnet
)));
}
let method_name = valid_subslice(
Expand Down Expand Up @@ -126,8 +126,11 @@ impl RequestInPrep {
self.max_size_remote_subnet * self.multiplier_max_size_local_subnet;
if size as u64 > max_size_local_subnet.get() - current_size as u64 {
Err(HypervisorError::ContractViolation(format!(
"RequestInPrep: current_size {} exceeded the allowed limit local-subnet {} remote-subnet {}",
current_size, max_size_local_subnet, self.max_size_remote_subnet
"Request to {}:{} has a payload size of {}, which exceeds the allowed local-subnet limit of {}",
self.callee,
self.method_name,
current_size + size as usize,
max_size_local_subnet
)))
} else {
let data = valid_subslice("ic0.call_data_append", src, size, heap)?;
Expand Down Expand Up @@ -174,7 +177,9 @@ pub(crate) fn into_request(
let max_size_local_subnet = max_size_remote_subnet * multiplier_max_size_local_subnet;
if payload_size > max_size_local_subnet.get() {
return Err(HypervisorError::ContractViolation(format!(
"RequestInPrep: size of message {} exceeded the allowed remote-subnet limit {}",
"Request to {}:{} has a payload size of {}, which exceeds the allowed remote-subnet limit of {}",
destination_canister,
method_name,
payload_size, max_size_remote_subnet
)));
}
Expand Down

0 comments on commit 26fe0dd

Please sign in to comment.