Error
Reference for mo:core/Error in the core library.
Error wraps async rejection values and classification helpers for recovery
paths. Use it with the required try/catch style around awaits so failure
behavior is explicit in both code and specs.
Import
mo:core/Error
Status
- Runtime module
Public API
Types
Error,ErrorCode
Functions
reject(msg : Text) : Error
Reads or constructs the error value used by async rejection handling.
Contract
ensures message(result) == msg;
Use when: code or specifications need this operation with the documented contract.
code(error : Error) : ErrorCode
Reads or constructs the error value used by async rejection handling.
Use when: code or specifications need this operation with the documented contract.
message(error : Error) : Text
Reads or constructs the error value used by async rejection handling.
Use when: code or specifications need this operation with the documented contract.
isCleanReject(error : Error) : Bool
Checks the predicate described by the return contract.
Contract
ensures result == (switch (code error) {
case (#system_fatal or #system_transient or #destination_invalid or #call_error _) true;
case _ false
});
Use when: a branch condition or contract needs this predicate as a named fact.
isRetryPossible(error : Error) : Bool
Checks the predicate described by the return contract.
Contract
ensures result == (switch (code error) {
case (#system_transient or #system_unknown) true;
case _ false
});
Use when: a branch condition or contract needs this predicate as a named fact.
Summary
- Runtime module under
mo:core/Error. - Exposes 5 public functions.