executecatcherrors
PROGRAM
,
PARAMETERS

The executecatcherrors statement is the same as the execute statement, except for the fact that if an error occurs while running it can be trapped by an if error statement immediately following the executecatcherrors statement.


Parameters

This statement has two parameters:

program – is the text (source code) of the program you want to run.

parameters – is a list of parameters to be passed to the subroutine. This list is optional, you don’t have to pass any parameters if you don’t need to. See parameter( and setparameter for more information on accessing parameters within a subroutine.


Description

This statement is the same as the execute statement, but it allows the calling procedure to trap errors with the if error statement. Here is the basics of how this can be used.

local Code
Code = "  ... some ... code ... here "
executecatcherrors Code
if error
    message "Code runtime error:"+info("error")
endif

Note: We no longer recommend using this statement, instead, use the try and catch statements, like this.

local Code
Code = "  ... some ... code ... here "
try
    execute Code
catch
    message "Code runtime error:"+info("error")
endcatch

In fact, the way the executecatcherrors statement works is by simply adding try and catch statements to your code. The program

executecatcherrors Code

is exactly equivalent to:

execute "TRY "+Code+" CATCH RETURNERROR INFO("ERROR") ENDCATCH"

See Also


History

VersionStatusNotes
10.0UpdatedCarried over from Panorama 6.0 but now now allows parameters to be passed to and from the subroutine using the param( function and setparameter statement. Also, it is now ok to use executecatcherrors recursively.