Air-Trap 1.0.0
A multiplayer R-Type clone game engine built with C++23 and ECS architecture
Loading...
Searching...
No Matches
rtp::Error Class Referencefinal

Comprehensive error object with severity and retry tracking. More...

#include <Error.hpp>

Collaboration diagram for rtp::Error:

Public Member Functions

ErrorCode code (void) const noexcept
 Get the error code.
 
log::Level severity (void) const noexcept
 Get the severity level of this error.
 
std::uint8_t retryCount (void) const noexcept
 Get the current retry count.
 
auto message (void) const noexcept -> std::string_view
 Get the error message.
 
std::uint8_t incrementRetryCount (void) noexcept
 Increment the retry counter.
 

Static Public Member Functions

template<typename ... Args>
static auto failure (ErrorCode code, std::format_string< Args... > fmt, Args &&...args) -> Error
 Create a failure-level error.
 
template<typename ... Args>
static auto warning (ErrorCode code, std::format_string< Args... > fmt, Args &&...args) -> Error
 Create a warning-level error.
 
template<typename ... Args>
static auto fatal (ErrorCode code, std::format_string< Args... > fmt, Args &&...args) -> Error
 Create a fatal-level error.
 

Private Member Functions

 Error (ErrorCode code, log::Level severity, std::string_view msg)
 Private constructor for error creation.
 

Private Attributes

ErrorCode _code
 The error code.
 
log::Level _severity
 Severity level of the error.
 
std::uint8_t _retryCount {0}
 Number of retry attempts.
 
std::string _message
 Formatted error message.
 

Detailed Description

Comprehensive error object with severity and retry tracking.

The Error class provides a rich error representation that includes:

  • Error code from the ErrorCode enum
  • Severity level (warning, failure, fatal)
  • Formatted error message
  • Retry counter for recoverable errors

Factory methods are provided to create errors with different severity levels.

Definition at line 156 of file Error.hpp.

Constructor & Destructor Documentation

◆ Error()

rtp::Error::Error ( ErrorCode  code,
log::Level  severity,
std::string_view  msg 
)
private

Private constructor for error creation.

Parameters
codeThe error code
severityThe severity level
msgThe error message

Definition at line 65 of file Error.cpp.

Member Function Documentation

◆ code()

ErrorCode rtp::Error::code ( void  ) const
noexcept

Get the error code.

Returns
The ErrorCode of this error

Definition at line 85 of file Error.cpp.

Referenced by std::formatter< rtp::Error >::format().

◆ failure()

template<typename ... Args>
static auto rtp::Error::failure ( ErrorCode  code,
std::format_string< Args... >  fmt,
Args &&...  args 
) -> Error
static

Create a failure-level error.

Template Parameters
ArgsFormat argument types
Parameters
codeThe error code
fmtFormat string
argsFormat arguments
Returns
Error object with failure severity

Referenced by rtp::sys::impl::LibraryBackend::close(), rtp::log::configure(), rtp::thread::ThreadPool::create(), rtp::sys::LibraryManager::getOrLoadInternal(), rtp::sys::impl::LibraryBackend::getSymbol(), rtp::sys::LibraryManager::loadStandalone(), rtp::sys::impl::LibraryBackend::open(), and rtp::ecs::Registry::spawn().

◆ fatal()

template<typename ... Args>
static auto rtp::Error::fatal ( ErrorCode  code,
std::format_string< Args... >  fmt,
Args &&...  args 
) -> Error
static

Create a fatal-level error.

Template Parameters
ArgsFormat argument types
Parameters
codeThe error code
fmtFormat string
argsFormat arguments
Returns
Error object with fatal severity

◆ incrementRetryCount()

std::uint8_t rtp::Error::incrementRetryCount ( void  )
noexcept

Increment the retry counter.

Returns
The new retry count after incrementing

Definition at line 106 of file Error.cpp.

◆ message()

auto rtp::Error::message ( void  ) const -> std::string_view
noexcept

Get the error message.

Returns
String view of the formatted error message

Definition at line 100 of file Error.cpp.

Referenced by std::formatter< rtp::Error >::format().

◆ retryCount()

std::uint8_t rtp::Error::retryCount ( void  ) const
noexcept

Get the current retry count.

Returns
Number of times this error has been retried

Definition at line 95 of file Error.cpp.

◆ severity()

log::Level rtp::Error::severity ( void  ) const
noexcept

Get the severity level of this error.

Returns
The log level representing error severity

Definition at line 90 of file Error.cpp.

Referenced by std::formatter< rtp::Error >::format().

◆ warning()

template<typename ... Args>
static auto rtp::Error::warning ( ErrorCode  code,
std::format_string< Args... >  fmt,
Args &&...  args 
) -> Error
static

Create a warning-level error.

Template Parameters
ArgsFormat argument types
Parameters
codeThe error code
fmtFormat string
argsFormat arguments
Returns
Error object with warning severity

Member Data Documentation

◆ _code

ErrorCode rtp::Error::_code
private

The error code.

Definition at line 236 of file Error.hpp.

◆ _message

std::string rtp::Error::_message
private

Formatted error message.

Definition at line 239 of file Error.hpp.

◆ _retryCount

std::uint8_t rtp::Error::_retryCount {0}
private

Number of retry attempts.

Definition at line 238 of file Error.hpp.

◆ _severity

log::Level rtp::Error::_severity
private

Severity level of the error.

Definition at line 237 of file Error.hpp.


The documentation for this class was generated from the following files: