ErrorMsg Property

Applies to TestComplete 14.71, last modified on April 22, 2021

Description

The RegExpr.ErrorMsg property returns the description for the error specified by an error code.

Declaration

RegExprObj.ErrorMsg(AErrorId)

Read-Only Property String
RegExprObj An expression, variable or parameter that specifies a reference to a RegExpr object
AErrorId [in]    Required    Integer    

Applies To

The property is applied to the following object:

Parameters

The property has the following parameter:

AErrorId

Specifies the error identifier code.

Property Value

The string holding the description of the error.

Example

The following example demonstrates how to use the RegExpr.Compile method to force expression conversion and to get conversion errors that occur during compilation.

DelphiScript

procedure CompileSample;
var
  MyRegExp: OleVariant;
  Mes: string;
  Err, Pos: integer;
begin

  MyRegExp:=HISUtils.RegExpr;
  try
    // Specifies a regular expression
    MyRegExp.Expression := '[]';
    // Forces expression conversion
    MyRegExp.Compile;
    // Performs operations over text
    …
  except
    // If a compilation error occurs…
    // Obtains the code of the occurred error
    Err := MyRegExp.LastError;
    // Obtains the description of the occurred error
    Mes := MyRegExp.ErrorMsg[Err];
    // Obtains the position, in the regular expression, where the error occurred
    Pos := MyRegExp.CompilerErrorPos;
    // Posts information on the error to the test log
    Log.Error('Error: ' + aqConvert.IntToStr(Err) + ' ' + Mes + ' (pos ' + aqConvert.IntToStr(Pos) + ')');
  end;
end;

See Also

Regular Expressions Syntax
Using Regular Expressions in Scripts
Expression Property
Compile Method
LastError Property
RegExpr.CompilerErrorPos

Highlight search results