aqUtils.SysErrorMessage Method

Applies to TestComplete 15.70, last modified on December 17, 2024

Description

The aqUtils.SysErrorMessage method returns the description of the specified Windows system error code. You can use this method, for example, to get the description of errors returned by the aqFileSystem and aqFile object methods.

Common system error codes and their descriptions are listed in this MSDN article:

System Error Codes

Declaration

aqUtils.SysErrorMessage(ErrorCode)

ErrorCode [in]    Required    Integer    
Result String

Applies To

The method is applied to the following object:

Parameters

The method has the following parameter:

ErrorCode

The error code.

Result Value

The description of the specified error code.

If the specified number is not a valid error code, SysErrorMessage returns an empty string.

Example

The following script tries to create a file with an invalid name and posts the system error description to the test log.

JavaScript, JScript

function SysErrorMessageTest()
{
  var result = aqFile.Create("C:\\<Invalid*File*Name>.txt");

  if (result == 0)
  {
    // This never happens
    Log.Message("The file was created successfully.");
  }
  else
  {
    var strError = aqUtils.SysErrorMessage(result);
    Log.Message("Error " + result + ": " + strError);
  }
}

// Result:
// Error 123: The filename, directory name, or volume label syntax is incorrect.

Python

def SysErrorMessageTest():
  result = aqFile.Create("C:\\<Invalid*File*Name>.txt")
  if result == 0:
    # This never happens
    Log.Message("The file was created successfully.")
  else:
    strError = aqUtils.SysErrorMessage(result)
    Log.Message("Error " + str(result) + ": " + strError)
# Result:
# Error 123: The filename, directory name, or volume label syntax is incorrect.

VBScript

Sub SysErrorMessageTest
  Dim result, strError
  result = aqFile.Create("C:\<Invalid*File*Name>.txt")

  If result = 0 Then
    ' This never happens
    Call Log.Message("The file was created successfully.")
  Else
    strError = aqUtils.SysErrorMessage(result)
    Call Log.Message("Error " & result & ": " & strError)
  End If
End Sub

' Result:
' Error 123: The filename, directory name, or volume label syntax is incorrect.

DelphiScript

procedure SysErrorMessageTest;
var res, strError;
begin
  res := aqFile.Create('C:\<Invalid*File*Name>.txt');

  if res = 0 then
    // This never happens
    Log.Message('The file was created successfully.')
  else
  begin
    strError := aqUtils.SysErrorMessage(res);
    Log.Message('Error ' + VarToStr(res) + ': ' + strError);
  end;
end;

// Result:
// Error 123: The filename, directory name, or volume label syntax is incorrect.

C++Script, C#Script

function SysErrorMessageTest()
{
  var result = aqFile["Create"]("C:\\<Invalid*File*Name>.txt");

  if (result == 0)
  {
    // This never happens
    Log["Message"]("The file was created successfully.");
  }
  else
  {
    var strError = aqUtils["SysErrorMessage"](result);
    Log["Message"]("Error " + result + ": " + strError);
  }
}

// Result:
// Error 123: The filename, directory name, or volume label syntax is incorrect.

See Also

Win32Check Method

Highlight search results