ExceptionPos returns an exception parameter value that indicates the position of the generated exception.

ExceptionPos can also be used in conjunction with the ExceptionToString function to better identify the location of the exception and its cause.

Declaration: function ExceptionPos: Cardinal;

The example that follows uses LogInfo so that the Action completes irrespective of the exception error. LogWarning or LogError could also be used. LogError will terminate the Action and prevent any further processing.

procedure ScriptEvent (var Value : variant);
var
Int1, Int2, Int3 : integer;
begin
//Try to divide an integer by zero - to raise an exception
try
Int1 := 10;
Int2 := 0;
Int3 := Int1 / Int2;
//These lines will execute if no error
LogInfo('Fabulous!');
LogInfo('There was no problem encountered!');
except
LogInfo('Exception occurred in position # '+IntToStr(ExceptionPos));
LogInfo('Exception occurred: ' + ExceptionToString(ExceptionType, ExceptionParam));
LogInfo('');
LogInfo('ERROR: '+ExceptionToString(ExceptionType, ExceptionParam)+' The error occurred in position: '+IntToStr(ExceptionPos));
end;
LogInfo('');
LogInfo('The Action has completed.');
 
end;