23 #include <string_view>
24 #include <unordered_map>
31 namespace diagnostics {
56 void report_error(
const ErrorInfo& error);
67 void clear_callbacks();
84 void set_enabled(
bool enabled);
89 bool is_enabled()
const;
105 std::vector<ErrorInfo> get_errors_by_component(std::string_view component)
const;
111 std::vector<ErrorInfo> get_recent_errors(
size_t count = 10)
const;
117 bool has_errors(std::string_view component)
const;
124 size_t get_error_count(std::string_view component,
ErrorLevel level)
const;
133 mutable std::mutex mutex_;
134 std::vector<ErrorCallback> callbacks_;
136 std::atomic<bool> enabled_{
true};
139 mutable std::mutex stats_mutex_;
141 std::vector<ErrorInfo> recent_errors_;
142 std::unordered_map<std::string, std::vector<ErrorInfo>> errors_by_component_;
144 static constexpr
size_t MAX_RECENT_ERRORS = 1000;
146 void update_stats(
const ErrorInfo& error);
147 void notify_callbacks(
const std::vector<ErrorCallback>& callbacks,
const ErrorInfo& error);
148 void add_to_recent_errors(
const ErrorInfo& error);
149 void add_to_component_errors(
const ErrorInfo& error);
155 namespace error_reporting {
165 const boost::system::error_code& ec,
bool retryable =
true);
175 std::string_view message,
bool retryable =
false);
184 std::string_view message);
202 const boost::system::error_code& ec = boost::system::error_code{});
218 UNILINK_API void report_info(std::string_view component, std::string_view operation, std::string_view message);
Centralized error handling system.
std::function< void(const ErrorInfo &)> ErrorCallback
void report_warning(std::string_view component, std::string_view operation, std::string_view message)
Report warning (non-critical issue)
void report_memory_error(std::string_view component, std::string_view operation, std::string_view message)
Report memory-related error.
void report_configuration_error(std::string_view component, std::string_view operation, std::string_view message)
Report configuration error.
void report_communication_error(std::string_view component, std::string_view operation, std::string_view message, bool retryable)
Report communication-related error.
void report_connection_error(std::string_view component, std::string_view operation, const boost::system::error_code &ec, bool retryable)
Report connection-related error.
void report_system_error(std::string_view component, std::string_view operation, std::string_view message, const boost::system::error_code &ec)
Report system-level error.
void report_info(std::string_view component, std::string_view operation, std::string_view message)
Report informational message.
ErrorLevel
Error severity levels.
Comprehensive error information structure.
Error statistics for monitoring.