Skip to content

Latest commit

 

History

History
210 lines (127 loc) · 4.5 KB

ErrorCode.md

File metadata and controls

210 lines (127 loc) · 4.5 KB

ErrorCode

class ErrorCode

Required header: <Eclog/Error.h>

The ErrorCode class represents an error code, which can be compared to success (See Success) or a named constant in the error code enumeration (See ErrorCodeEnum). An error code also holds an error object (See Error), which can provide structured error information like an exception.

Member functions

Name Description
(constructor) Constructor.
destructor Destructor.
operator= Copy assignment.
operator bool Checks if the error code is not equal to success.
operator! Checks if the error code is equal to success.
operator== Compares the error code with another error code or a named constant.
operator!= Compares the error code with another error code or a named constant.
message Gets the error message.
error Gets the error object.

Non-member functions

Name Description
operator== Compares a named constant with an error code.
operator!= Compares a named constant with an error code.
operator<< Insert error message into stream.

(constructor)

ErrorCode();                                                        (1)
ErrorCode(const ErrorCode& other);                                  (2)

Constructs an ErrorCode.

(1) Default constructor. Constructs an error code equal to success (See Success).

(2) Copy constructor.

Parameters

ErrorCode& other Another error code.


(destructor)

~ErrorCode();

Destroys the ErrorCode.


operator=

ErrorCode& operator=(const ErrorCode& other);

Copy assignment.

Parameters

ErrorCode& other Another error code.

Return value

ErrorCode& Reference to *this.


operator bool

operator BoolType() const;

Checks if the error code is not equal to success (See Success).

Return value

BoolType true if the error code is not equal to success, false otherwise.


operator!

bool operator!() const;

Checks if the error code is equal to success (See Success).

Return value

BoolType true if the error code is equal to success, false otherwise.


operator== and operator!=

bool operator==(const ErrorCode& other) const;
bool operator!=(const ErrorCode& other) const;
bool operator==(ErrorCodeEnum e) const;
bool operator!=(ErrorCodeEnum e) const;
bool operator==(Success) const;
bool operator!=(Success) const;

Compares the error code with another error code or a named constant.

Parameters

ErrorCode& other Another error code to compare.

ErrorCodeEnum e Named constant to compare.

Success Success to compare.

Return value

bool true if the corresponding comparison holds, false otherwise.


message

const char* message() const;

Gets the error message.

Return value

const char* The error message.


error

const Error& error() const;

Gets the error object.

Return value

const Error& Reference to the error object.


operator== and operator!=

bool operator==(Success a, const ErrorCode& b);
bool operator!=(Success a, const ErrorCode& b);
bool operator==(ErrorCodeEnum a, const ErrorCode& b);
bool operator!=(ErrorCodeEnum a, const ErrorCode& b);

Compares a named constant with an error code.

Parameters

Success a Success to compare.

ErrorCodeEnum a Named constant to compare.

const ErrorCode& b Error code to compare.

Return value

bool true if the corresponding comparison holds, false otherwise.


operator<<

std::ostream& operator<<(std::ostream& stream, const ErrorCode& ec);

Insert error message into stream.

Parameters

std::ostream& stream The stream where characters are inserted.

const ErrorCode& ec Error code to get the error message from.

Return value

std::ostream& The same as parameter stream.