Exactly! Maybe this summarizes the intention of a canister well:
- Trap (via
assert false
, or soonDebug.trap
): “I am completely lost, better be safe and don’t record any state changes”. Same as division by 0 for example. - Rejecting (via
throw
): “The call cannot be performed, likely because the caller did something stupid, but I am still pretty sure that my state is in good order, so it can be committed”. Also “Call failed, but I maybe want to record the fact that this caller tried something”. - Replying, with
null
or#error "messages"
: “The caller did everything right, I am also still healthy, and and as part of the expected way of things I am returning some kind of negative result (e.g. key not present in a key value store)”. - Replying, with data: “All well, here you go, have a good day”.