error

Description

Utility class for generating errors. Has a base distinction between critical and recoverable errors. Additional code ids can be provided to the constructor if additional distinctions are necessary.

Vars

code

error_code_

bool

is_critical_

std::variant< std::string_view, std::string >

error_message_

Methods

error ( error::code, bool )

error ( error::code, bool, const std::string_view & )

error ( error::code, bool, std::string && )

error ( error && )

SAW_FORBID_COPY ( error )

error &

operator= ( error && )

const std::string_view

get_message ( )

const std::string_view

get_category ( )

bool

failed ( )

bool

is_critical ( )

bool

is_recoverable ( )

error

copy_error ( )

code

get_id ( )

bool

is_type ( )


Vars Description

code error_code_

Type representing the error code used to distinguish the different error types

bool is_critical_

Helper variable for ease of checking if it’s a critical error.

std::variant< std::string_view, std::string > error_message_

Member holding the message. It’s a variant for edge cases where we are out of memory.

Methods Description

error ( error::code, bool )


error ( error::code, bool, const std::string_view & )


error ( error::code, bool, std::string && )


error ( error && )


SAW_FORBID_COPY ( error )


error & operator= ( error && )


const std::string_view get_message ( )

Returns a string view to the message

const std::string_view get_category ( )

Returns a string view which describes which error this is.

bool failed ( )

Checks if it’s an error at all, since 0 is reserved for no error.

bool is_critical ( )

Checks if the error is critical.

bool is_recoverable ( )

Checks if the error is recoverable.

error copy_error ( )

Replaces the copy constructor. We need this since we want to explicitly copy and not implicitly

code get_id ( )

Return the id.

bool is_type ( )

Provide an error struct and check if it matches the type