DelphiScript - Exception Handling

Applies to TestComplete 15.63, last modified on April 10, 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,

DelphiScript

Raise('Invalid data');

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

DelphiScript

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

Notes:

  • 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
Raise
ExceptionMessage

Highlight search results