[Overview][Constants][Types][Classes][Index] Reference for unit 'ptc' (#ptc)

TPTCError

[Properties (by Name)] [Methods (by Name)] [Events (by Name)]

An error message.

Declaration

Source position: errord.inc line 34

type TPTCError = class

public

  procedure Create();

  

Creates an error object with a specified error message.

  destructor Destroy; override;

  

Destructor.

  procedure Assign();

  

  function Equals(); override;

  

  procedure Report;

  

Reports the error and terminates the program.

  property Message: String; [r]

  

Gets the error message string.

end;

Inheritance

TPTCError

  

An error message.

|

TObject

Description

An error message.

The error class represents an error message. It provides a uniform interface for error reporting and handling via the Object Pascal exception mechanism. Error exceptions may be caught and recovered from:

try
  { open the console at 640x480 resolution }
  console.Open('Error example', 640, 480);
except
  on error: TPTCError do
  begin
    { fallback to default resolution }
    console.Open('Error example');
  end;
end;

Or allowed to fall through to the main try/except block and get reported to the user:

try
  { open the console at 640x480 resolution }
  console.Open('Error example', 640, 480);
except
  on error: TPTCError do
  begin
    { report error }
    error.Report;
  end;
end;