In some cases it is necessary to interrupt the flow of execution with
a failure: this is where the predefined function
failwith comes in.
The failwith function raises an error that cannot be caught, which terminates the contract.
The call to failwith should be annotated with a type as the type-checker cannot infer the correct type yet.
Assertions can be used to ensure a certain condition is met when
running a contract. The predefined function
assert is used to check
whether a given a Boolean condition is true. The function
assert_some is used to check if an option value is not
assert_some_with_error is like
assert_some but an error
message can be given. When a condition is not met, the contract will
stop executing and display an error.
You can use
assert_some_with_error to use a custom error message