Error Handling

Script Exceptions

All exceptions thrown by any script task execution are sub types of ScriptingException.

ScriptingException and sub types
Figure 1. ScriptingException and sub types

Script Task Abortion by Exception

The script task can throw an ScriptClientExecutionException to abort the execution of an IScriptTask, and display a meaningful message to the user.

Stop script task execution by throwing an ScriptClientExecutionException
scriptTask("TaskName"){

    code{
        // Stop the execution and display a message to the user
        throw new ScriptClientExecutionException("Message to the User")
    }
}

Exception with Console Return Code

An ScriptClientExecutionException with an return code of type Integer will also abort the execution of the IScriptTask.

But it also changes the return code of the console application, if the IScriptTask was executed in the console application. This could be used when the console application of the DaVinci Configurator is called for other scripts or batch files.

Changing the return code of the console application by throwing an ScriptClientExecutionException
scriptTask("TaskName"){

    code{
        // The return code will be returned by the DvCmd.exe process
        def returnCode = 50
        throw new ScriptClientExecutionException(returnCode, "Message to the User")
    }
}

Reserved Return Codes

The returns codes 0-20 are reversed for internal use of the DaVinci Configurator, and are not allowed to be used by a client script. Also negative returns codes are not permitted.

Unhandled Exceptions from Tasks

When a script task execution throws any type of Exception (more precise Throwable) the script task is marked as failed and the Exception is reported to the user.