[Overview][Constants][Types][Classes][Index] |
Creates an error object with a specified error message.
Source position: line 0
public constructor TPTCError.Create; |
const AMessage: String |
); |
const AMessage: String; |
const AError: TPTCError |
); |
const AError: TPTCError |
); |
AMessage |
|
The error message. |
AMessage |
|
The error message. |
AError |
|
The compounding error. |
AError |
|
The compounding error. |
Creates an error object.
When called without arguments, the error message of the created object is initialized to ''. When AMessage is specified, an error object is created with an error message of AMessage. Here is an example of typical use:
{ do something ... } failure := DoSomething; { check failure } if failure then begin { error message } raise TPTCError.Create('do something failed'); end;
When both AMessage and AError are specified as arguments, the error object is created with the text message and the error object message compounded. The AMessage parameter is the first line of the error message, a newline is inserted in the string, and the error object message is added to the end. Here is an example of typical use:
try { do something low level... } failure := DoSomethingLowLevel; { check failure } if failure then begin { error message } raise TPTCError.Create('low level failure'); end; except on error: TPTCError do begin { error message } raise TPTCError.Create('high level failure', error); end; end;
The error message constructed in the except block has a compound message of 'high level failure'+newline+'low level failure'.