error.h¶
| File Path | engine/include/conjure/core/error.h |
| API ↗ | Errors and results |
A recoverable failure: category, code and a human readable message. Engine code returns these through result<T> instead of throwing. A default-constructed error means "no error".
Structs¶
| File | Description |
|---|---|
error_category_traits<error_code> |
|
std::formatter<conjure::core::error> |
|
std::formatter<conjure::core::error_code> |
Classes¶
| File | Description |
|---|---|
error |
A recoverable failure: category, code and a human readable message. Engine code returns these through result<T> instead of throwing. A default-constructed error means "no error". |
Enumerations¶
error_code¶
enum class error_code : u16 {
NONE = 0,
UNKNOWN,
INVALID_ARGUMENT,
INVALID_STATE,
NOT_FOUND,
ALREADY_EXISTS,
OUT_OF_RANGE,
OUT_OF_MEMORY,
UNSUPPORTED,
NOT_IMPLEMENTED,
IO_FAILURE,
PARSE_FAILURE,
TIMEOUT,
PERMISSION_DENIED,
BACKEND_FAILURE,
DEPENDENCY_FAILURE,
CANCELLED,
COUNT
};
Generic failures that any module may return. Module-specific conditions get their own enum.
Type Aliases¶
error_code_name_fn¶
Function that names a code of one category. Returns "" for unknown values.
Concepts¶
error_enum¶
template <typename EnumType> concept error_enum = std::is_enum_v<EnumType> && requires { { error_category_traits<EnumType>::NAME } -> std::convertible_to<std::string_view>; { error_category_traits<EnumType>::ID } -> std::convertible_to<u32>; { error_category_traits<EnumType>::code_name(u32{}) } -> std::convertible_to<std::string_view>; };
Forward Declarations¶
error_category_traits¶
Binds an error enumeration to a category. Specialised through CONJURE_DECLARE_ERROR_CATEGORY.
Functions¶
Public¶
detail::core_error_code_name¶
detail::core_error_code_name¶[[nodiscard]] CONJURE_API std::string_view core_error_code_name(u32 code) noexcept;make_error¶
make_error¶template <error_enum EnumType, typename... Args> requires(sizeof...(Args) > 0) [[nodiscard]] error make_error(
EnumType code,
std::format_string<Args...> format,
Args &&...args);Builds an error from an enumerator with a std::format style message and at least one argument.
template <error_enum EnumType> [[nodiscard]] error make_error(
EnumType code,
std::string_view detail = {});Builds an error from an enumerator with a fixed detail message (possibly empty).
to_string¶
to_string¶[[nodiscard]] CONJURE_API std::string_view to_string(
error_code code) noexcept;Returns the stable, upper-case name of a generic error code (e.g. "NOT_FOUND").