Error Class Reference

This class to capture error information from library function calls. More...

Public Member Functions

  operator bool () const noexcept

Checks whether this object is in an error state.

bool  isError () const noexcept

Checks whether this object is in an error state.

bool  isSuccess () const noexcept

Checks whether this object is in a success state.

ErrorCode  code () const noexcept

Returns the error code.

std::string  message () const

Returns the error message.

Static Public Member Functions

static Error Ignore ()

An error handler that ignores all errors.

static Error Throw ()

An error handler that throws all errors.

static Error Default ()

The default error handler.

Detailed Description

This class to capture error information from library function calls.

See Error Handling for a general overview of how error handling works in this library.

Member Function Documentation

◆ code()

ErrorCode code ( ) const
inlinenoexcept

Returns the error code.

Returns
The error code of the operation that filled this error object.

◆ Default()

Error & Default ( )
inlinestatic

The default error handler.

The err parameter of all library functions is set to Default() by default.

If a function that got Default() passed as its err parameter, the behavior is as follows:

Returns
An error handler following the default procedure described above.
See also
Error Handling

◆ Ignore()

Error & Ignore ( )
inlinestatic

An error handler that ignores all errors.

If an error occurs during a function call its argument set to Ignore(), errors are ignored.

The return value of the function can still signal a possible error condition.

Returns
An error handler that ignores all errors.
See also
Error Handling

◆ isError()

bool isError ( ) const
inlinenoexcept

Checks whether this object is in an error state.

Returns
true, if this error's code is not equal to ErrorCode::NoError, otherwise false.
See also
isSuccess

◆ isSuccess()

bool isSuccess ( ) const
inlinenoexcept

Checks whether this object is in a success state.

Returns
true, if this error's code is equal to ErrorCode::NoError, otherwise false.
See also
isError

◆ message()

std::string message ( ) const
inline

Returns the error message.

Returns
The error message generated by the failed operation that filled this error object.
If no error occurred, an empty string is returned.

◆ operator bool()

operator bool ( ) const
inlineexplicitnoexcept

Checks whether this object is in an error state.

Returns
true, if this error's code is not equal to ErrorCode::NoError, otherwise false.
See also
isError
isSuccess

◆ Throw()

Error & Throw ( )
inlinestatic

An error handler that throws all errors.

If an error occurs during a function call with its err argument set to Throw(), IC4Exception is thrown.

Returns
An error handler that throws all errors as a IC4Exception.
See also
Error Handling