Raises an assert_err() if the specified expression evaluates to false.
This function does not generate a change.
assert(expression [, error_msg])
| Argument | Type | Description |
|---|---|---|
| expression | any (required) | The expression to evaluate. |
| error_msg | str (optional) | Custom error message. |
Returns nil if the type of the expression evaluates to true. Otherwise
an assert_err() is raised.
In versions before v0.9.4 the return value of assert(..) used to be the return value from the expression (when evaluated as true).
This code shows how assert can be used:
assert(1 > 2, 'one is still smaller than two');
Raises an assert_err() exception
{
"error_msg": "one is still smaller than two",
"error_code": -50
}