Monitoring System 0.1.0
System resource monitoring with pluggable collectors and alerting
Loading...
Searching...
No Matches
kcenon::monitoring::error_info Struct Reference

Extended error information with context. More...

#include <result_types.h>

Collaboration diagram for kcenon::monitoring::error_info:
Collaboration graph

Public Member Functions

 error_info (monitoring_error_code c, const std::string &msg="", const std::optional< std::string > &ctx=std::nullopt)
 
std::string to_string () const
 Get formatted error string.
 
common::error_info to_common_error () const
 Convert to common_system error_info.
 

Static Public Member Functions

static error_info from_common_error (const common::error_info &common_err)
 Create from common_system error_info.
 

Public Attributes

monitoring_error_code code
 
std::string message
 
std::optional< std::string > context {std::nullopt}
 

Detailed Description

Extended error information with context.

Provides monitoring-specific error information that integrates with common_system's error handling.

Examples
graceful_degradation_example.cpp, health_reliability_example.cpp, and result_pattern_example.cpp.

Definition at line 35 of file result_types.h.

Constructor & Destructor Documentation

◆ error_info()

kcenon::monitoring::error_info::error_info ( monitoring_error_code c,
const std::string & msg = "",
const std::optional< std::string > & ctx = std::nullopt )
inline

Definition at line 40 of file result_types.h.

43 : code(c)
44 , message(msg.empty() ? error_code_to_string(c) : msg)
45 , context(ctx) {}
std::string error_code_to_string(monitoring_error_code code)
Convert error code to string representation.
std::optional< std::string > context
monitoring_error_code code

Member Function Documentation

◆ from_common_error()

static error_info kcenon::monitoring::error_info::from_common_error ( const common::error_info & common_err)
inlinestatic

Create from common_system error_info.

Definition at line 73 of file result_types.h.

73 {
74 error_info info(static_cast<monitoring_error_code>(common_err.code),
75 common_err.message);
76 if (common_err.details) {
77 info.context = common_err.details;
78 }
79 return info;
80 }
monitoring_error_code
Comprehensive error codes for monitoring system operations.
Definition error_codes.h:25
@ info
Informational, no action required.
error_info(monitoring_error_code c, const std::string &msg="", const std::optional< std::string > &ctx=std::nullopt)

References kcenon::monitoring::info.

Referenced by kcenon::monitoring::error_boundary< T >::execute(), kcenon::monitoring::retry_executor< T >::execute(), and kcenon::monitoring::error_boundary< T >::handle_failure().

Here is the caller graph for this function:

◆ to_common_error()

common::error_info kcenon::monitoring::error_info::to_common_error ( ) const
inline

Convert to common_system error_info.

Examples
graceful_degradation_example.cpp.

Definition at line 62 of file result_types.h.

62 {
63 common::error_info info(static_cast<int>(code), message, "monitoring_system");
64 if (context) {
65 info.details = context;
66 }
67 return info;
68 }

References code, context, kcenon::monitoring::info, and message.

Referenced by kcenon::monitoring::aggregation_processor::add_aggregation_rule(), unreliable_service::call(), kcenon::monitoring::health_monitor::check(), kcenon::monitoring::opentelemetry_tracer_adapter::convert_spans(), demonstrate_error_boundaries(), kcenon::monitoring::error_boundary< T >::execute(), kcenon::monitoring::opentelemetry_compatibility_layer::export_metrics(), kcenon::monitoring::otlp_metrics_exporter::export_metrics(), kcenon::monitoring::prometheus_exporter::export_metrics(), kcenon::monitoring::statsd_exporter::export_metrics(), kcenon::monitoring::otlp_metrics_exporter::export_snapshot(), kcenon::monitoring::prometheus_exporter::export_snapshot(), kcenon::monitoring::statsd_exporter::export_snapshot(), kcenon::monitoring::jaeger_exporter::export_spans(), kcenon::monitoring::opentelemetry_compatibility_layer::export_spans(), kcenon::monitoring::otlp_exporter::export_spans(), kcenon::monitoring::otlp_grpc_exporter::export_spans(), kcenon::monitoring::zipkin_exporter::export_spans(), kcenon::monitoring::trace_context::from_w3c_traceparent(), kcenon::monitoring::time_series::query(), kcenon::monitoring::simple_http_client::send(), kcenon::monitoring::otlp_metrics_exporter::send_via_grpc(), kcenon::monitoring::otlp_metrics_exporter::send_via_http(), kcenon::monitoring::jaeger_exporter::send_with_retry(), kcenon::monitoring::zipkin_exporter::send_with_retry(), kcenon::monitoring::health_monitor::unregister_check(), kcenon::monitoring::alert_rule::validate(), kcenon::monitoring::monitoring_config::validate(), kcenon::monitoring::time_series_buffer_config::validate(), kcenon::monitoring::time_series_config::validate(), kcenon::monitoring::time_series_query::validate(), validate_range(), and kcenon::monitoring::ring_buffer< T >::write().

Here is the caller graph for this function:

◆ to_string()

std::string kcenon::monitoring::error_info::to_string ( ) const
inline

Get formatted error string.

Returns
Formatted error message with context information

Definition at line 51 of file result_types.h.

51 {
52 std::string result = "[" + error_code_to_string(code) + "] " + message;
53 if (context.has_value()) {
54 result += " Context: " + context.value();
55 }
56 return result;
57 }

References code, context, kcenon::monitoring::error_code_to_string(), and message.

Here is the call graph for this function:

Member Data Documentation

◆ code

monitoring_error_code kcenon::monitoring::error_info::code

Definition at line 36 of file result_types.h.

Referenced by to_common_error(), and to_string().

◆ context

std::optional<std::string> kcenon::monitoring::error_info::context {std::nullopt}

Definition at line 38 of file result_types.h.

38{std::nullopt};

Referenced by to_common_error(), and to_string().

◆ message

std::string kcenon::monitoring::error_info::message

Definition at line 37 of file result_types.h.

Referenced by to_common_error(), and to_string().


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