Monitoring System 0.1.0
System resource monitoring with pluggable collectors and alerting
Loading...
Searching...
No Matches
error_codes.h
Go to the documentation of this file.
1#pragma once
2
3// BSD 3-Clause License
4// Copyright (c) 2025, 🍀☀🌕🌥 🌊
5// See the LICENSE file in the project root for full license information.
6
7
16#include <cstdint>
17#include <string>
18
19namespace kcenon { namespace monitoring {
20
40enum class monitoring_error_code : std::int32_t {
41 // Success
42 success = 0,
43
44 // Collection errors (-300 to -306)
46 collection_failed = -301,
49 collector_disabled = -304,
52
53 // Storage errors (-310 to -316)
54 storage_full = -310,
55 storage_corrupted = -311,
56 compression_failed = -312,
60 storage_empty = -316,
61
62 // Configuration errors (-320 to -324)
64 invalid_interval = -321,
65 invalid_capacity = -322,
68
69 // System errors (-330 to -335)
71 permission_denied = -331,
72 out_of_memory = -332,
74 operation_timeout = -334,
76
77 // Integration errors (-340 to -343)
82
83 // Metrics errors (-345 to -349)
84 metric_not_found = -345,
86 metric_overflow = -347,
87 aggregation_failed = -348,
88 processing_failed = -349,
89
90 // Health check errors (-350 to -352)
94
95 // Fault tolerance errors (-355 to -364)
99 operation_failed = -358,
100 network_error = -359,
101 service_unavailable = -360,
102 service_degraded = -361,
104 fallback_failed = -363,
105 recovery_failed = -364,
106
107 // General errors (-365 to -371)
108 invalid_argument = -365,
109 invalid_state = -366,
110 not_found = -367,
111 already_exists = -368,
112 resource_exhausted = -369,
113 already_started = -370,
114 dependency_missing = -371,
115
116 // Resource management errors (-375 to -380)
117 quota_exceeded = -375,
118 rate_limit_exceeded = -376,
119 cpu_throttled = -377,
121 bandwidth_exceeded = -379,
123
124 // Data consistency errors (-385 to -392)
125 transaction_failed = -385,
126 transaction_timeout = -386,
127 transaction_aborted = -387,
128 validation_failed = -388,
129 data_corrupted = -389,
130 state_inconsistent = -390,
131 deadlock_detected = -391,
132 rollback_failed = -392,
133
134 // Unknown error (band floor)
135 unknown_error = -399
136};
137
144 switch (code) {
146 return "Success";
147
148 // Collection errors
150 return "Collector not found";
152 return "Collection failed";
154 return "Collector initialization failed";
156 return "Collector already exists";
158 return "Collector is disabled";
160 return "Invalid collector configuration";
162 return "Monitoring is disabled";
163
164 // Storage errors
166 return "Storage is full";
168 return "Storage is corrupted";
170 return "Compression failed";
172 return "Storage not initialized";
174 return "Storage write failed";
176 return "Storage read failed";
178 return "Storage is empty";
179
180 // Configuration errors
182 return "Invalid configuration";
184 return "Invalid interval";
186 return "Invalid capacity";
188 return "Configuration not found";
190 return "Configuration parse error";
191
192 // System errors
194 return "System resource unavailable";
196 return "Permission denied";
198 return "Out of memory";
200 return "Memory allocation failed";
202 return "Operation timeout";
204 return "Operation cancelled";
205
206 // Integration errors
208 return "Thread system not available";
210 return "Logger system not available";
212 return "Incompatible version";
214 return "Adapter initialization failed";
215
216 // Metrics errors
218 return "Metric not found";
220 return "Invalid metric type";
222 return "Metric overflow";
224 return "Aggregation failed";
225
226 // Health check errors
228 return "Health check failed";
230 return "Health check timeout";
232 return "Health check not registered";
233
234 // Fault tolerance errors
236 return "Circuit breaker is open";
238 return "Circuit breaker is half-open";
240 return "Retry attempts exhausted";
242 return "Operation failed";
244 return "Network error";
246 return "Service unavailable";
248 return "Service operating in degraded mode";
250 return "Error boundary triggered";
252 return "Fallback operation failed";
254 return "Recovery operation failed";
255
256 // General errors
258 return "Invalid argument";
260 return "Invalid state";
262 return "Not found";
264 return "Already exists";
266 return "Resource exhausted";
268 return "Already started";
270 return "Dependency missing";
271
272 // Resource management errors
274 return "Quota exceeded";
276 return "Rate limit exceeded";
278 return "CPU throttled";
280 return "Memory quota exceeded";
282 return "Bandwidth exceeded";
284 return "Resource unavailable";
285
286 // Data consistency errors
288 return "Transaction failed";
290 return "Transaction timeout";
292 return "Transaction aborted";
294 return "Validation failed";
296 return "Data corrupted";
298 return "State inconsistent";
300 return "Deadlock detected";
302 return "Rollback failed";
303
304 // Unknown error
306 default:
307 return "Unknown error";
308 }
309}
310
316inline std::string get_error_details(monitoring_error_code code) {
317 switch (code) {
319 return "The specified collector was not found. Check collector name and ensure it's registered.";
321 return "Storage capacity exceeded. Consider increasing buffer size or reducing collection frequency.";
323 return "Configuration validation failed. Review configuration parameters and constraints.";
325 return "Thread system integration not available. Ensure thread_system is properly linked.";
327 return "Circuit breaker is open, rejecting calls to protect downstream services. Wait for recovery or check service health.";
329 return "All retry attempts have been exhausted. The operation failed permanently. Check service availability and error conditions.";
331 return "The requested operation failed. Check service status, network connectivity, and input parameters.";
333 return "Service is operating in degraded mode due to detected issues. Some features may be unavailable.";
335 return "Error boundary has been triggered to prevent error propagation. Check upstream service health.";
337 return "Both primary operation and fallback mechanism failed. Check alternative service configurations.";
339 return "Resource quota has been exceeded. Reduce resource consumption or increase quota limits.";
341 return "Rate limit has been exceeded. Reduce request frequency or increase rate limits.";
343 return "Operation has been throttled due to high CPU usage. Reduce system load or adjust CPU limits.";
345 return "Memory quota has been exceeded. Free memory or increase memory quota limits.";
347 return "Bandwidth quota has been exceeded. Reduce data transfer or increase bandwidth limits.";
349 return "Required resource is currently unavailable. Try again later or check resource status.";
351 return "Transaction failed to complete successfully. Check operation prerequisites and system state.";
353 return "Transaction exceeded its timeout limit. Consider increasing timeout or reducing transaction scope.";
355 return "Transaction was aborted due to conflicts or errors. Review transaction operations and retry.";
357 return "Data validation failed. Check data integrity and consistency requirements.";
359 return "Data corruption detected. Run data repair operations or restore from backup.";
361 return "System state is inconsistent across components. Synchronization or recovery needed.";
363 return "Deadlock detected in transaction processing. Review locking strategy and transaction ordering.";
365 return "Transaction rollback failed. Manual cleanup may be required to restore consistent state.";
366 default:
367 return error_code_to_string(code);
368 }
369}
370
371} } // namespace kcenon::monitoring
std::string error_code_to_string(monitoring_error_code code)
Convert error code to string representation.
monitoring_error_code
Comprehensive error codes for monitoring system operations.
Definition error_codes.h:40
std::string get_error_details(monitoring_error_code code)
Get detailed error message.