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

TPTCError.Report

Reports the error and terminates the program.

Declaration

Source position: errord.inc line 45

public procedure TPTCError.Report;

Description

Reports the error and terminates the program with exit code 1. The error is reported in the most natural method of the platform. For example, UNIX systems would print the error message to stderr, Win32 systems would display a message box, DOS systems would output to stdout etc. Typically this function is used in combination with wrapping the main program with a try/except block to ensure that all unhandled error exceptions are caught and reported to the user.

begin
  try
    { main program ... }
  except
    on error: TPTCError do
    begin
      { report error }
      error.Report;
    end;
  end;
end.