Welcome to the new DelphiDabbler Code Library Documentation.

This is a new site that's currently running on alpha code. There are going to be bugs. If you discover any, please report them on the site's issues page (GitHub account required). Thanks.

Warning: Many URLs are going to change. Refer to the README file to discover which library project's documentation has been completed.

ErrorCode property

Project: Console Application Runner Classes

Unit: PJConsoleApp

Classes: TPJCustomConsoleApp, TPJConsoleApp

Applies to: ~>3.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 set†. The error codes specific to the console application runner classes are:

Error code (hex) Constant Description
$20000001 cAppErrorTimeOut Application timed out (see the MaxExecTime property).
$20000002 cAppErrorTerminated Application was forcibly terminated (see the Terminate method).

† 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;

Alternatively use the IsApplicationError function to check for application errors.

The property is public in TPJConsoleApp and protected in TPJCustomConsoleApp.