Skip to content

Latest commit

 

History

History
163 lines (95 loc) · 3.11 KB

Error.md

File metadata and controls

163 lines (95 loc) · 3.11 KB

Error

class Error

Inherited by: BadCast, IOError, LogicError, OutOfMemory, ParseError, RuntimeError, and UnicodeError.

Required header: <Eclog/Error.h>

The Error abstract class provides a consistent interface for the error inheritance hierarchy.

Each specific type of error has a corresponding named constant in the error code enumeration (See ErrorCodeEnum) and a unique identifier (See ErrorId).

Member functions

Name Description
isA Checks if the error object is of a specific type.
getId Gets the identifier of the error.
equals Compares the error with another error.
clone Makes a copy of the error.
message Gets the error message.
id Returns the identifier of this class.

Non-member functions

Name Description
cast Converts an error object up and down along the inheritance hierarchy.

isA

template<typename T>
bool isA() const;

virtual bool isA(const ErrorId& id) const;

Checks if the error object is of a specific type (or a subtype of a specific type).

Template parameters

T The type of error to compare to.

Parameters

const ErrorId& id Reference to an error identifier.

Return value

bool true if the error object is of the specific type, false otherwise.


getId

virtual const ErrorId& getId() const;

Gets the identifier of the error.

Return value

ErrorId& Reference to the identifier.


equals

virtual bool equals(const Error* other, bool strict) const;

Compares the error with another error.

If strict is false, this function will compare only two error identifiers. Otherwise, the details of the two errors will be further compared.

Parameters

const Error* other Pointer to another error.

bool strict Strict mode.

Return value

bool true if the error is equal to other, false otherwise.


clone

virtual const Error* clone() const;

Makes a copy of the error object.

Return value

const Error* Pointer to the copy.


message

virtual const char* message() const;

Gets the error message.

Return value

const char* The error message.


id

static const ErrorId& id();

Returns the identifier of this class.

Return value

ErrorId& Reference to the identifier.


cast

template<typename T>
const T& cast(const Error& err);

Converts an error object up and down along the inheritance hierarchy.

Template parameters

T The type of error to cast to.

Parameters

const Error& err An error object to cast.

Return value

const T& Reference to the error object.

Error

A BadCast fault occurs if the error object is not of the specific type.