IceShard 1
A personal game engine project, with development focused on 2D/2.5D games.
Loading...
Searching...
No Matches
ice::ErrorCode Struct Reference

Compile-time defined error code with extended information. More...

#include <ice/error.hxx>

Inheritance diagram for ice::ErrorCode:
ice::ErrorCodeError ice::ErrorCodeSuccess

Public Member Functions

constexpr ErrorCode (char const *definition) noexcept
constexpr auto type () const noexcept -> char
constexpr auto code () const noexcept -> ice::i32
constexpr auto category () const noexcept -> std::string_view
constexpr auto description () const noexcept -> std::string_view
constexpr operator bool () const noexcept
 Implicit cast to a boolean value.
constexpr operator i32 () const noexcept
 Explicit conversion operator to i32 value.

Public Attributes

char const * value

Detailed Description

Compile-time defined error code with extended information.

Error codes defined with this structure provide four different information values.

  • type - Either S standing for Success or E standing for Error.
  • code - Number value assigned to this error code. Value between 0 and 9999. (should be unique to ensure easy error identification)
  • category - User readable value that can be used to quickly indentify the source project of the error.
  • description - User readable description of the error that can be logged to the output or other locations.

Although error codes should be mainly used to report errors and problems that resulted in expected behavior not being executed, it is allowed to defined a Success code, and provide additional information if necessary. For example: "Loading an asset succeeded but because editor data was not parsable, debug settings were reset."

Remarks
Currently error codes also follow some specific error ranges.
  • [0000 - 2000) - Core engine codes
  • [2000 - 4000) - Framework codes
  • [4000 - 9999] - Game codes

Constructor & Destructor Documentation

◆ ErrorCode()

ice::ErrorCode::ErrorCode ( char const * definition)
explicitconstexprnoexcept

Member Function Documentation

◆ category()

auto ice::ErrorCode::category ( ) const -> std::string_view
constexprnoexcept
Returns
Category of the error. May allow quicker identification of the actual issue.

◆ code()

auto ice::ErrorCode::code ( ) const -> ice::i32
constexprnoexcept
Returns
Parsed number value found in the definition string.

◆ description()

auto ice::ErrorCode::description ( ) const -> std::string_view
constexprnoexcept
Returns
Description of the error.

◆ operator bool()

ice::ErrorCode::operator bool ( ) const
inlineconstexprnoexcept

Implicit cast to a boolean value.

Returns
true if this error code is considered a Success value, false otherwise.

◆ operator i32()

ice::ErrorCode::operator i32 ( ) const
inlineexplicitconstexprnoexcept

Explicit conversion operator to i32 value.

◆ type()

auto ice::ErrorCode::type ( ) const -> char
constexprnoexcept
Returns
Character that defines the error code type. (either S or E)

Member Data Documentation

◆ value

char const* ice::ErrorCode::value

The documentation for this struct was generated from the following file: