Skip to content

Engine → Core → error.h

error

Syntax

class CONJURE_API error

Constructors

AccessSignatureDescription
publicerror();
publicexplicit error( error_code code);
publicerror( error_code code, std::string message);
publicerror( u32 category, u32 code, const char *categoryName, error_code_name_fn codeName, std::string message);
publicerror( const error &) = default;
publicerror( error &&) noexcept = default;

Destructors

AccessSignatureDescription
public~error();

Variables

AccessNameTypeDefaultDescription
privatemCategoryu320
privatemCategoryNameconst char *""
privatemCodeu320
privatemCodeNameerror_code_name_fnnullptr
privatemMessagestd::string{}

Functions

Public

category

[[nodiscard]] u32 category() const noexcept;

FNV-1a 32 hash of the category name. A default-constructed error carries the core category (error_category_traits<error_code>::ID) with code NONE; test for "no error" with is(error_code::NONE), not with category() == 0.

category_name

[[nodiscard]] std::string_view category_name() const noexcept;

The category's registered name ("core", "ecs", ...).

code

[[nodiscard]] u32 code() const noexcept;

The raw code within the category.

code_name

[[nodiscard]] std::string_view code_name() const noexcept;

The enumerator name of the code within its category, or "" when unknown.

from

template <error_enum EnumType> [[nodiscard]] static error from(
    EnumType code,
    std::string message = {});

Builds an error from a module error enumerator.

generic_code

[[nodiscard]] error_code generic_code() const noexcept;

The generic code when this error belongs to the core category, otherwise NONE.

is

template <error_enum EnumType> [[nodiscard]] bool is(
    EnumType code) const noexcept;

True when this error carries exactly this code of this category.

is_category

template <error_enum EnumType> [[nodiscard]] bool is_category() const noexcept;

True when this error belongs to the category bound to the given enumeration.

message

[[nodiscard]] const std::string &message() const noexcept;

Human readable detail; may be empty.

to_string

[[nodiscard]] std::string to_string() const;

"category.CODE: message", or "category.CODE" when there is no message.

Operator Overloads

Public

operator=

error &operator=(
    const error &) = default;
error &operator=(
    error &&) noexcept = default;

operator==

[[nodiscard]] bool operator==(
    const error &other) const noexcept;