This functionality is only available for certain module packages.

Abort scripts using the AbortExecutionIfErrorCommand

The execution of an action is terminated by the command Engineering.AbortExecutionIfErrorCommand, if a script enters an error in the UserMessageCollector.

The following example code shows a scenario of a complex script. If an error occurs the script result (viz. the created changes to the model) should not be stored. The associated action is as follows:

If an error occurs, in the accompanying ScriptCommand an error is mentioned in the UserMessageCollector and the internal recursive and iterative script processing is terminated. This can be done without the use of exceptions via a global abortExecution flag or by the UserScriptException. The UserScriptException has an ID and an optional text to be given. Thus, within scripting, various termination conditions are handled. This also functions for calls of scripts in scripts. An exception, which is thrown in a subscript, can be handled in the calling script.