unilink  0.4.3
A simple C++ library for unified async communication
unilink::diagnostics::ErrorHandler Class Reference

Centralized error handling system. More...

#include <error_handler.hpp>

Public Types

using ErrorCallback = std::function< void(const ErrorInfo &)>
 

Public Member Functions

 ErrorHandler ()
 
 ~ErrorHandler ()
 
void report_error (const ErrorInfo &error)
 Report an error. More...
 
void register_callback (ErrorCallback callback)
 Register error callback. More...
 
void clear_callbacks ()
 Unregister all callbacks. More...
 
void set_min_error_level (ErrorLevel level)
 Set minimum error level to report. More...
 
ErrorLevel get_min_error_level () const
 Get current minimum error level. More...
 
void set_enabled (bool enabled)
 Enable/disable error reporting. More...
 
bool is_enabled () const
 Check if error reporting is enabled. More...
 
ErrorStats get_error_stats () const
 Get error statistics. More...
 
void reset_stats ()
 Reset error statistics. More...
 
std::vector< ErrorInfoget_errors_by_component (std::string_view component) const
 Get errors by component. More...
 
std::vector< ErrorInfoget_recent_errors (size_t count=10) const
 Get recent errors. More...
 
bool has_errors (std::string_view component) const
 Check if component has any errors. More...
 
size_t get_error_count (std::string_view component, ErrorLevel level) const
 Get error count for specific component and level. More...
 

Static Public Member Functions

static ErrorHandlerinstance ()
 Get singleton instance. More...
 
static ErrorHandlerdefault_handler ()
 

Detailed Description

Centralized error handling system.

Provides thread-safe error reporting, statistics collection, and callback-based error handling for the entire unilink library.

Definition at line 39 of file error_handler.hpp.

Member Typedef Documentation

◆ ErrorCallback

using unilink::diagnostics::ErrorHandler::ErrorCallback = std::function<void(const ErrorInfo&)>

Definition at line 41 of file error_handler.hpp.

Constructor & Destructor Documentation

◆ ErrorHandler()

unilink::diagnostics::ErrorHandler::ErrorHandler ( )
default

◆ ~ErrorHandler()

unilink::diagnostics::ErrorHandler::~ErrorHandler ( )
default

Member Function Documentation

◆ clear_callbacks()

void unilink::diagnostics::ErrorHandler::clear_callbacks ( )

Unregister all callbacks.

Definition at line 65 of file error_handler.cc.

◆ default_handler()

ErrorHandler & unilink::diagnostics::ErrorHandler::default_handler ( )
static

Definition at line 33 of file error_handler.cc.

◆ get_error_count()

size_t unilink::diagnostics::ErrorHandler::get_error_count ( std::string_view  component,
ErrorLevel  level 
) const

Get error count for specific component and level.

Parameters
componentComponent name
levelError level

Definition at line 115 of file error_handler.cc.

◆ get_error_stats()

ErrorStats unilink::diagnostics::ErrorHandler::get_error_stats ( ) const

Get error statistics.

Definition at line 78 of file error_handler.cc.

◆ get_errors_by_component()

std::vector< ErrorInfo > unilink::diagnostics::ErrorHandler::get_errors_by_component ( std::string_view  component) const

Get errors by component.

Parameters
componentComponent name to filter by

Definition at line 88 of file error_handler.cc.

◆ get_min_error_level()

ErrorLevel unilink::diagnostics::ErrorHandler::get_min_error_level ( ) const

Get current minimum error level.

Definition at line 72 of file error_handler.cc.

◆ get_recent_errors()

std::vector< ErrorInfo > unilink::diagnostics::ErrorHandler::get_recent_errors ( size_t  count = 10) const

Get recent errors.

Parameters
countMaximum number of recent errors to return

Definition at line 97 of file error_handler.cc.

◆ has_errors()

bool unilink::diagnostics::ErrorHandler::has_errors ( std::string_view  component) const

Check if component has any errors.

Parameters
componentComponent name to check

Definition at line 109 of file error_handler.cc.

◆ instance()

ErrorHandler & unilink::diagnostics::ErrorHandler::instance ( )
static

Get singleton instance.

Definition at line 38 of file error_handler.cc.

◆ is_enabled()

bool unilink::diagnostics::ErrorHandler::is_enabled ( ) const

Check if error reporting is enabled.

Definition at line 76 of file error_handler.cc.

◆ register_callback()

void unilink::diagnostics::ErrorHandler::register_callback ( ErrorCallback  callback)

Register error callback.

Parameters
callbackFunction to call when errors occur

Definition at line 60 of file error_handler.cc.

◆ report_error()

void unilink::diagnostics::ErrorHandler::report_error ( const ErrorInfo error)

Report an error.

Parameters
errorError information to report

Definition at line 40 of file error_handler.cc.

◆ reset_stats()

void unilink::diagnostics::ErrorHandler::reset_stats ( )

Reset error statistics.

Definition at line 83 of file error_handler.cc.

◆ set_enabled()

void unilink::diagnostics::ErrorHandler::set_enabled ( bool  enabled)

Enable/disable error reporting.

Parameters
enabledTrue to enable, false to disable

Definition at line 74 of file error_handler.cc.

◆ set_min_error_level()

void unilink::diagnostics::ErrorHandler::set_min_error_level ( ErrorLevel  level)

Set minimum error level to report.

Parameters
levelMinimum level (errors below this level are ignored)

Definition at line 70 of file error_handler.cc.


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