Class AnException

DescriptionHierarchyFieldsMethodsProperties

Unit

Declaration

type AnException = class(APrintingObject)

Description

A basic exception.

This is the base class used by all exceptions in causerie. It provides methods for constructing and printing readable error messages to both stderr and instances of AStream.

Hierarchy

Overview

Fields

Protected myCode: longword;
Protected myMessage: string;

Methods

Public constructor because(errorCode: integer);
Public constructor because(const msg: string);
Public constructor because(errorCode: integer; const msg: string);
Public constructor because(const msg: string; details: array of const);
Public constructor because(errorCode: integer; const msg: string; details: array of const);
Public function init: boolean; override;
Public procedure print;
Public function shallowCopyFrom(const Other: AnObject): boolean; override;
Public function toString: string; override;
Public function code: longword;
Public function message: string; virtual;

Description

Fields

Protected myCode: longword;

Stores the error code, if any, associated with the exception

Protected myMessage: string;

Refers to the exception mesage text.

This text is printed as part of the message output when AnException.print or AnException.toString is called.

Methods

Public constructor because(errorCode: integer);

Constructs a new instance of AnException with the specified error code.

The error message stored by the new instance is set to errDefaultMessage.

Public constructor because(const msg: string);

Constructs a new instance of AnException with the specified message.

The error code stored by the new instance is set to zero (0).

Public constructor because(errorCode: integer; const msg: string);

Constructs a new instance of AnException with the specified error code and message.

Public constructor because(const msg: string; details: array of const);

Constructs a new instance of AnException using the specified format string and details.

msg should be a format string that, when combined with the contents of details, will result in an error message that indicates the nature of the exception.

Public constructor because(errorCode: integer; const msg: string; details: array of const);

Constructs a new instance of AnException using the specified error code, format string, and details.

msg should be a format string that, when combined with the contents of details, will result in an error message which indicates the nature of the exception.

Public function init: boolean; override;

Initializer

Public procedure print;

Writes the exception to stderr.

This method calls AnException.toString and prints the result of that call to stderr.

Public function shallowCopyFrom(const Other: AnObject): boolean; override;

Construct a shallow copy of the other object.

This method overrides the behavior inherited from AnObject.shallowCopyFrom: it calls that method, then checks to see whether Other is an instance of AnException. If so, it copies the values of:

to Self from Other, overwriting any values in Self.

Public function toString: string; override;

Constructs and returns a string representation of the exception, suitable for printing to a stream or display.

The base implementation of this method will construct a string that contains the error code, if any, as well as the error message associated with the exception. Descendant classes may override this method to produce different output.

Public function code: longword;

Retrieves the error code associated with the exception.

Public function message: string; virtual;

Retrieves the error message associated with the exception.

The base implementation of this method does NOT return the fully-formed string that is returned by AnException.toString; it simply returns the error message as defined during construction, or the default error message if none was provided when the instance was constructed.


Generated by PasDoc 0.13.0 on 2015-01-10 17:13:18