Skip to main content
Version: 8.1

try

This function is used by Ignition's Expression language.

Description​

This expression is used to suppress errors caused by other expressions. The first expression will be executed, and if it executes successfully, its value will be used. However, if there is an error evaluating it, the value of failover will be used. When the failover is used, the data quality will be set by the failover value.

Syntax​

switch(value, case, [caseN, ...], return, [returnN, ...], returnDefault)

Parameters​

TypeParameterDescription
ObjectvalueThe value to check against the case values.
ObjectcaseA value to check against. Can include any number of case values.
ObjectreturnA value to return for the matching case. Must match the number of case values.
ObjectreturnDefaultThe default value to return if no case is matched.

Returns​

Object - The return value for the case that matched the value, or the returnDefault value if no matches were found.

Examples​

Code Snippet
try(toInteger("boom"), -1) // returns -1 with a quality code of 192 (good)
Code Snippet
// fetch an integer value from the first row of a table. Return -1 if there are no rows
try({Root Container.Power Table.data}[0, 'Integer Column'], -1)