I have a function that performs subtraction but panics with an error
Panicked at 'Cannot subtract b from a because b is larger than a.', /home/abc/.cargo/registry/src/index.crates.io-6f17d22bba15001f/num-bigint-0.4.6/src/biguint/subtraction.rs:69:5, error code None
The problem is that the function panics but executes the next line which depends on subtraction and that is why I printed the logs below. Because the current function test fails but the sub-sequent test pass successfully.
> Code
add_execution_logs(
format!(" Amount- Fee {} - {} ", current_amount.clone(), fee.clone()),
);
let new_amount: Nat = if current_amount.clone() > fee.clone() {
current_amount.clone() - fee.clone()
} else {
return (format!(
"Amount- Fee {} - {} ",
current_amount.clone(),
fee.clone()
));
};
> Logs
{ message: ' Amount- Fee 1_000_000_000 - 100_000 ' }
Candid crate