I often stumble upon horrible Candid errors which take up to 1 hour to figure.
For me personally, that’s one of the worst parts of the dev experience, so now that I know how things work better, I went and fixed it.
When it occurs: Writing dapps with agentjs, using nested structures in your calls, and not providing correct input.
Before: You basically get the whole record dumped with no specific reason given
Example:
Pull Request:
Errors look like this now:
[Error: Invalid record {arg:vec nat8; wasm_module:vec nat8; mode:variant {reinstall; upgrade; install}; canister_id:principal} argument:
field canister_id -> Invalid principal argument: "rrkah-fqaaa-aaaaa-aaaaq-cai"]
- It follows the nested structure and chains thrown errors, so no matter how deep you go, you will see where the problem is - pinpointed.
- Cuts long values (you don’t want a 2mb blob inside your error)
- Works with the current tests and shouldn’t introduce breaking changes