god::encoding_error#

Note

Declared in <god/encoding.hpp>

class encoding_error#

Represents an error encountered when verifying UTF-8 encoding

Members

std::string message = "undocumented encoding error"#

The message to display upon exit.

int return_code = 1#

The number to exit with.

std::vector<unsigned char> chars#

The offending character.

std::size_t line_index#

The line in which the error was encountered.

Constructors

encoding_error(std::string pmsg, const std::string &pbadstr, std::size_t index)#

Main constructor for the encoding_error class.

Parameters:
  • pmsg – The error message

  • pbadstr – Constant reference to the offending string

  • index – The line index the error occurred on

encoding_error(const std::string &pbadstr, std::size_t index)#

Alternative constructor with no message.

Parameters:
  • pbadstr – Constant reference to the offending string

  • index – The line index the error occurred on

Methods

bool operator==(const encoding_error &other) const = default#

Boolean comparison operator.

Parameters:

other – Another encoding_error to compare

Returns:

true if they are identical, false otherwise

encoding_error &msg(std::string s) noexcept#

Set the error’s message.

Parameters:

s – The new message

Returns:

A reference to the error; chainable

std::string_view msg() const noexcept#

Get the error’s message.

Returns:

A view of the message string

std::string context() const noexcept#

Obtain context regarding the error.

Returns:

The error context string

encoding_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 code.

Returns:

The error’s return code integer

void quit() const noexcept#

Exit with the return code.

void die() const noexcept#

Display the error message and exit.