Skip to main content



throw

A irScript throw statement is used to raise an error from the current point of execution. Such errors can be handled in irScript using try/catch/finally statements. A throw statement requires a single accompanying expression (of any type), used to provide additional context for error handlers:

var listOfErrors = [];

try
{
throw 'Something bad happened';
}
catch( error )
{
listOfErrors.Add( error.Value );
}

try
{
throw { ErrorCode : 45, Message : 'Something \*really\* bad happened.' };
}
catch( error )
{
if( error.Value.ErrorCode > 10 )
{
listOfErrors.Add( error.Value.Message );
}
}

Inside a catch block, a caught error may be re-thrown by issuing another throw statement, using the caught error as the target:

var listOfErrors = []; 
try
{
try
{
throw 'Something bad happened';
}
catch( e )
{
throw e;
}
}
catch( e )
{
listOfErrors.Add( e.Value );
}

// listOfErrors now contains a single Text element 'Something bad happened'