god::error#

Note

Declared in <god/base.hpp>

class error#

A basic error for general usage.

Members

std::string message = "undocumented error"#

The message to display.

int return_code = 1#

The code to exit with.

Constructors

inline error(std::string msg, int rc)#

Main constructor for the error class.

inline error(std::string msg)#

Alternate contstructor recieving only a message.

Methods

inline bool operator==(const error &other) const noexcept#

Boolean comparison overload.

Parameters:

other – Another error to compare

Returns:

true if they are identical, false otherwise

error &msg(std::string str) noexcept#

Set the error’s message.

Parameters:

str – The new error message

Returns:

A reference to the error; chainable

std::string_view msg() const noexcept#

Get the error’s message.

Returns:

A string_view of the error message

error &code(int rc) noexcept#

Set the error’s return code.

Parameters:

rc – The new return code

Returns:

A reference to the error; chainable

int code() const noexcept#

Get the error’s return code.

Returns:

The error’s return code

void quit() const noexcept#

Call exit() with the error’s return_code.

void die() const noexcept#

Display the error message and exit with return_code.