source code
source code
Key is Principal:
import HashMap "mo:base/HashMap";
import Principal "mo:base/Principal";
actor Example {
var map = HashMap.HashMap<Principal, Nat>(1, Principal.equal, Principal.hash);
public func example(i: Principal) {
map.delete(i);
};
};
Key is Nat:
import HashMap "mo:base/HashMap";
import Hash "mo:base/Hash";
import Nat "mo:base/Nat";
actor Example {
var map = HashMap.HashMap<Nat, Nat>(1, Nat.equal, Hash.hash);
public func example(i: Nat) {
map.delete(i);
};
};
log
call logout
Key is Principal:
➜ temp git:(master) ✗ sudo dfx canister call test example '(principal "ryjl3-tyaaa-aaaaa-aaaba-cai")'
The Replica returned an error: code 5, message: "Canister ryjl3-tyaaa-aaaaa-aaaba-cai trapped explicitly: bigint function error"
➜ temp git:(master) ✗ sudo dfx canister call test example '(principal "as74e-clvxo-uxwuz-5dn2d-mqv2o-cwziv-iiemi-ckej2-yfwu6-zmj5u-mae")'
The Replica returned an error: code 5, message: "Canister ryjl3-tyaaa-aaaaa-aaaba-cai trapped: integer division by 0"
Key is Nat:
➜ temp git:(master) ✗ sudo dfx canister call test example '(0)'
The Replica returned an error: code 5, message: "Canister ryjl3-tyaaa-aaaaa-aaaba-cai trapped: integer division by 0"
➜ temp git:(master) ✗ sudo dfx canister call test example '(1)'
The Replica returned an error: code 5, message: "Canister ryjl3-tyaaa-aaaaa-aaaba-cai trapped: integer division by 0"
➜ temp git:(master) ✗ sudo dfx canister call test example '(2)'
The Replica returned an error: code 5, message: "Canister ryjl3-tyaaa-aaaaa-aaaba-cai trapped explicitly: bigint function error"
➜ temp git:(master) ✗ sudo dfx canister call test example '(3)'
The Replica returned an error: code 5, message: "Canister ryjl3-tyaaa-aaaaa-aaaba-cai trapped: integer division by 0"
➜ temp git:(master) ✗ sudo dfx canister call test example '(4)'
The Replica returned an error: code 5, message: "Canister ryjl3-tyaaa-aaaaa-aaaba-cai trapped explicitly: bigint function error"
➜ temp git:(master) ✗ sudo dfx canister call test example '(5)'
The Replica returned an error: code 5, message: "Canister ryjl3-tyaaa-aaaaa-aaaba-cai trapped explicitly: bigint function error"
I looked for similar log case, and it is caused by different reasons: