Skip to main content

assert(code)

Triggers a runtime error if the expression evaluates to false

Availability

Device + Agent

Parameters

Name Type Description
code Expression Squirrel code that can be evaluated to true or false

Returns

Nothing

Description

This function evaluates the passed expression, which can be a function call, a variable assignment or value reading, or any other line of Squirrel code.

If the expression evaluates to false, a Squirrel runtime exception is raised: the message “assertion failed” will be logged and the imp or agent will warm boot to restart the code. If this is undesirable behavior, the assert() statement may be embedded in a try... catch structure to trap the exception.

If the expression passed top assert() evaluates to true, no action is taken and code continues to execute with the next line.