Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

LMD-ScriptPack: Unable to catch specific exceptions

We have encountered a problem with the LMD ScriptPack when using exception handling within the script. We have followed the PasScripts Reference instructions regarding exception handling, but the execution of scripts do not run as expected.

We have the problem that we cannot catch typed exceptions in the except block.
To explain the behavior I give here 2 example scripts:

begin
  try
    raise Exception.Create('Some Error!');
  except
    on E: Exception do
      ShowMessage('Exception-Error: ' + E.Message);
    else
      ShowMessage('Other-Error');
  end; 
  ShowMessage('After Exception');
end;


In this script the first block is not run as expected ("Exception-Error"). Instead the else block is executed after the raise ("Other-Error"). The exception was caught at this point and the message "After Exception" will also pop up in the end.

begin
  try
    raise Exception.Create('
Some Error!');
  except
    on E: Exception do
      ShowMessage('Exception-Error: ' + E.Message);
  end; 
  ShowMessage('After Exception');
end;


In this second example without the else block, the expected on-exception block is also not executed in the except. The raise exception is not caught inside the script, which is why the script terminates with the exception.

Can you confirm the misbehavior?

Comments

Sign In or Register to comment.