DelphiDabbler Wiki



Console Application Runner ClassesErrorCode property

Project: Console Application Runner Classes

Unit: PJConsoleApp

Classes: TPJCustomConsoleApp, TPJConsoleApp

Introduced: v1.0

property ErrorCode: LongWord;

Description

This read only property provides information about any error that occurred while attempting to run a console application. The property is set to zero if the application was executed successfully.

Error codes either correspond to Windows error codes or are set by this class. Error codes set by the class have bit 29 set1. The error codes specific to the console application runner classes are:

Error code (hex)ConstantDescription
$20000001cAppErrorTimeOutApplication timed out (see the MaxExecTime property).
$20000002cAppErrorTerminatedApplication was forcibly terminated (see the Terminate method).

1 According to the Windows API documentation, error codes with bit 29 set are reserved for application use.

Remarks

This property only represents errors in executing the console application (for example program not found, timed-out, terminated etc.). Errors that occur within the application are not reported via ErrorCode. Console applications usually report such errors via their exit code. The exit code is exposed via the ExitCode property.

To check for application errors, use the constants from the table and AND them with the cAppErrorMask constant. For example:

if (ErrorCode and cAppErrorTimeout) <> 0 then
  // Do something;

[v2.0] Alternatively use the IsApplicationError function to check for application errors.

The property is public in TPJConsoleApp and protected in TPJCustomConsoleApp.

Page last modified on November 02, 2011, at 02:13 PM