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
25enum class monitoring_error_code : std::uint32_t {
26 // Success
27 success = 0,
28
29 // Collection errors (1000-1999)
31 collection_failed = 1001,
34 collector_disabled = 1004,
37
38 // Storage errors (2000-2999)
39 storage_full = 2000,
40 storage_corrupted = 2001,
41 compression_failed = 2002,
45 storage_empty = 2006,
46
47 // Configuration errors (3000-3999)
49 invalid_interval = 3001,
50 invalid_capacity = 3002,
53
54 // System errors (4000-4999)
56 permission_denied = 4001,
57 out_of_memory = 4002,
59 operation_timeout = 4004,
61
62 // Integration errors (5000-5999)
67
68 // Metrics errors (6000-6999)
69 metric_not_found = 6000,
71 metric_overflow = 6002,
72 aggregation_failed = 6003,
73 processing_failed = 6004,
74
75 // Health check errors (7000-7999)
79
80 // Fault tolerance errors (8000-8099)
84 operation_failed = 8003,
85 network_error = 8004,
87 service_degraded = 8006,
89 fallback_failed = 8008,
90 recovery_failed = 8009,
91
92 // General errors (8100-8999)
93 invalid_argument = 8100,
94 invalid_state = 8101,
95 not_found = 8102,
96 already_exists = 8103,
97 resource_exhausted = 8104,
98 already_started = 8105,
99 dependency_missing = 8106,
100
101 // Resource management errors (8200-8299)
102 quota_exceeded = 8200,
103 rate_limit_exceeded = 8201,
104 cpu_throttled = 8202,
106 bandwidth_exceeded = 8204,
108
109 // Data consistency errors (8300-8399)
110 transaction_failed = 8300,
111 transaction_timeout = 8301,
112 transaction_aborted = 8302,
113 validation_failed = 8303,
114 data_corrupted = 8304,
115 state_inconsistent = 8305,
116 deadlock_detected = 8306,
117 rollback_failed = 8307,
118
119 // Unknown error
120 unknown_error = 9999
121};
122
129 switch (code) {
131 return "Success";
132
133 // Collection errors
135 return "Collector not found";
137 return "Collection failed";
139 return "Collector initialization failed";
141 return "Collector already exists";
143 return "Collector is disabled";
145 return "Invalid collector configuration";
147 return "Monitoring is disabled";
148
149 // Storage errors
151 return "Storage is full";
153 return "Storage is corrupted";
155 return "Compression failed";
157 return "Storage not initialized";
159 return "Storage write failed";
161 return "Storage read failed";
163 return "Storage is empty";
164
165 // Configuration errors
167 return "Invalid configuration";
169 return "Invalid interval";
171 return "Invalid capacity";
173 return "Configuration not found";
175 return "Configuration parse error";
176
177 // System errors
179 return "System resource unavailable";
181 return "Permission denied";
183 return "Out of memory";
185 return "Memory allocation failed";
187 return "Operation timeout";
189 return "Operation cancelled";
190
191 // Integration errors
193 return "Thread system not available";
195 return "Logger system not available";
197 return "Incompatible version";
199 return "Adapter initialization failed";
200
201 // Metrics errors
203 return "Metric not found";
205 return "Invalid metric type";
207 return "Metric overflow";
209 return "Aggregation failed";
210
211 // Health check errors
213 return "Health check failed";
215 return "Health check timeout";
217 return "Health check not registered";
218
219 // Fault tolerance errors
221 return "Circuit breaker is open";
223 return "Circuit breaker is half-open";
225 return "Retry attempts exhausted";
227 return "Operation failed";
229 return "Network error";
231 return "Service unavailable";
233 return "Service operating in degraded mode";
235 return "Error boundary triggered";
237 return "Fallback operation failed";
239 return "Recovery operation failed";
240
241 // General errors
243 return "Invalid argument";
245 return "Invalid state";
247 return "Not found";
249 return "Already exists";
251 return "Resource exhausted";
253 return "Already started";
255 return "Dependency missing";
256
257 // Resource management errors
259 return "Quota exceeded";
261 return "Rate limit exceeded";
263 return "CPU throttled";
265 return "Memory quota exceeded";
267 return "Bandwidth exceeded";
269 return "Resource unavailable";
270
271 // Data consistency errors
273 return "Transaction failed";
275 return "Transaction timeout";
277 return "Transaction aborted";
279 return "Validation failed";
281 return "Data corrupted";
283 return "State inconsistent";
285 return "Deadlock detected";
287 return "Rollback failed";
288
289 // Unknown error
291 default:
292 return "Unknown error";
293 }
294}
295
301inline std::string get_error_details(monitoring_error_code code) {
302 switch (code) {
304 return "The specified collector was not found. Check collector name and ensure it's registered.";
306 return "Storage capacity exceeded. Consider increasing buffer size or reducing collection frequency.";
308 return "Configuration validation failed. Review configuration parameters and constraints.";
310 return "Thread system integration not available. Ensure thread_system is properly linked.";
312 return "Circuit breaker is open, rejecting calls to protect downstream services. Wait for recovery or check service health.";
314 return "All retry attempts have been exhausted. The operation failed permanently. Check service availability and error conditions.";
316 return "The requested operation failed. Check service status, network connectivity, and input parameters.";
318 return "Service is operating in degraded mode due to detected issues. Some features may be unavailable.";
320 return "Error boundary has been triggered to prevent error propagation. Check upstream service health.";
322 return "Both primary operation and fallback mechanism failed. Check alternative service configurations.";
324 return "Resource quota has been exceeded. Reduce resource consumption or increase quota limits.";
326 return "Rate limit has been exceeded. Reduce request frequency or increase rate limits.";
328 return "Operation has been throttled due to high CPU usage. Reduce system load or adjust CPU limits.";
330 return "Memory quota has been exceeded. Free memory or increase memory quota limits.";
332 return "Bandwidth quota has been exceeded. Reduce data transfer or increase bandwidth limits.";
334 return "Required resource is currently unavailable. Try again later or check resource status.";
336 return "Transaction failed to complete successfully. Check operation prerequisites and system state.";
338 return "Transaction exceeded its timeout limit. Consider increasing timeout or reducing transaction scope.";
340 return "Transaction was aborted due to conflicts or errors. Review transaction operations and retry.";
342 return "Data validation failed. Check data integrity and consistency requirements.";
344 return "Data corruption detected. Run data repair operations or restore from backup.";
346 return "System state is inconsistent across components. Synchronization or recovery needed.";
348 return "Deadlock detected in transaction processing. Review locking strategy and transaction ordering.";
350 return "Transaction rollback failed. Manual cleanup may be required to restore consistent state.";
351 default:
352 return error_code_to_string(code);
353 }
354}
355
356} } // 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:25
std::string get_error_details(monitoring_error_code code)
Get detailed error message.