Raises assert_err() if the specified statement evaluates to false.

This function does not generate an event.


assert(statement [, error_msg])


Argument Type Description
statement any (required) The statement to evaluate.
msg str (optional) Custom error message.

Return value

Assert returns the value of the given statement when it evaluates to true. Otherwise an assert_err() is raised.


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