DelphiScript - Exception Handling

Applies to TestComplete 15.65, last modified on June 25, 2024

Each unhandled exception stops script execution and posts an error message to the test log, with the text of the exception message. To handle exceptions during script execution, use the try... finally and try... except statements. Raise can be called without any parameters to re-raise the last exception. To raise the exception with a specific message string, use Raise with that string as a parameter. For instance,


Raise('Invalid data');

The ExceptionMessage function will return the last string posted as an exception message. For example:


 {do something here}
  Log.Error('Exception occurred: ' + ExceptionMessage);


  • The ExceptionMessage function cannot be evaluated in the Evaluate dialog.

  • If you have recursive code in the try block, after TestComplete exits the recursive loop, it will run the code in the except block regardless of whether any errors have occurred in the try block or not.

See Also

DelphiScript Reference

Highlight search results