Skip to main content
Version: 1.6.0

Failing

In some cases it is convenient to interrupt the flow of execution with a failure instead of a value: this is where the predefined function failwith comes in.

The failwith function raises an error that cannot be caught and terminates the execution of the contract.

const check =
(_param) : unit => failwith("This function always fails");

The call to failwith sometimes needs to be annotated with a type when the type-checker cannot infer the correct type, e.g. (failwith "message" : type_of_result).