1use waddling_errors::{ErrorCode, Severity};
8
9const ERR_INVALID_SALT: ErrorCode = ErrorCode::new(Severity::Error, "CRYPTO", "SALT", 1);
15const ERR_PARSE_FAILED: ErrorCode = ErrorCode::new(Severity::Error, "PARSER", "SYNTAX", 2);
16const ERR_AUTH_FAILED: ErrorCode = ErrorCode::new(Severity::Error, "AUTH", "CRED", 3);
17
18const WARN_DEPRECATED: ErrorCode = ErrorCode::new(Severity::Warning, "API", "DEPR", 1);
20const WARN_PERF_HIT: ErrorCode = ErrorCode::new(Severity::Warning, "PERF", "SLOW", 2);
21const WARN_EDGE_CASE: ErrorCode = ErrorCode::new(Severity::Warning, "VALID", "EDGE", 3);
22
23const CRIT_DATA_CORRUPT: ErrorCode = ErrorCode::new(Severity::Critical, "DATA", "CORRUPT", 1);
25const CRIT_SEC_BREACH: ErrorCode = ErrorCode::new(Severity::Critical, "SEC", "BREACH", 2);
26const CRIT_MEM_LEAK: ErrorCode = ErrorCode::new(Severity::Critical, "MEM", "LEAK", 3);
27
28const BLOCK_DEADLOCK: ErrorCode = ErrorCode::new(Severity::Blocked, "THREAD", "DEADLOCK", 1);
30const BLOCK_IO_WAIT: ErrorCode = ErrorCode::new(Severity::Blocked, "IO", "WAIT", 2);
31const BLOCK_NET_DOWN: ErrorCode = ErrorCode::new(Severity::Blocked, "NET", "DOWN", 3);
32
33const SUCCESS_BUILD: ErrorCode = ErrorCode::new(Severity::Success, "BUILD", "DONE", 1);
35const SUCCESS_TEST: ErrorCode = ErrorCode::new(Severity::Success, "TEST", "PASS", 2);
36
37const COMPLETE_PARSE: ErrorCode = ErrorCode::new(Severity::Completed, "PARSE", "DONE", 1);
39const COMPLETE_TYPECHECK: ErrorCode = ErrorCode::new(Severity::Completed, "TYPE", "CHECK", 2);
40
41const INFO_SERVER_START: ErrorCode = ErrorCode::new(Severity::Info, "SERVER", "START", 1);
43const INFO_CONFIG_LOAD: ErrorCode = ErrorCode::new(Severity::Info, "CONFIG", "LOAD", 2);
44
45const TRACE_THREAD_SPAWN: ErrorCode = ErrorCode::new(Severity::Trace, "PROBE", "THREAD", 1);
47const TRACE_LOCK_ACQUIRE: ErrorCode = ErrorCode::new(Severity::Trace, "PROBE", "LOCK", 2);
48
49fn print_error_analysis(code: &ErrorCode, description: &str) {
54 println!("╔══════════════════════════════════════════════════════════════╗");
55 println!("║ Code: {:<54} ║", code.code());
56 println!("║ Description: {:<47} ║", description);
57 println!("╠══════════════════════════════════════════════════════════════╣");
58 println!("║ Severity: {:<50} ║", format!("{:?}", code.severity()));
59 println!("║ Level: {:<53} ║", code.severity().level());
60 println!(
61 "║ Positive: {:<50} ║",
62 if code.severity().is_positive() {
63 "YES ✓"
64 } else {
65 "NO ✗"
66 }
67 );
68 println!("╚══════════════════════════════════════════════════════════════╝");
69 println!();
70}
71
72fn demonstrate_errors() {
73 println!("═══════════════════════════════════════════════════════════════");
74 println!(" ERROR (E): Operation failed");
75 println!(" Standard failures - invalid input, logic errors, etc.");
76 println!("═══════════════════════════════════════════════════════════════\n");
77
78 print_error_analysis(&ERR_INVALID_SALT, "Invalid salt length provided");
79 print_error_analysis(&ERR_PARSE_FAILED, "Syntax error in input");
80 print_error_analysis(&ERR_AUTH_FAILED, "Authentication credentials invalid");
81}
82
83fn demonstrate_warnings() {
84 println!("═══════════════════════════════════════════════════════════════");
85 println!(" WARNING (W): Potential issue or caveat");
86 println!(" Deprecated APIs, performance concerns, edge cases");
87 println!("═══════════════════════════════════════════════════════════════\n");
88
89 print_error_analysis(&WARN_DEPRECATED, "Using deprecated API");
90 print_error_analysis(&WARN_PERF_HIT, "Operation slower than expected");
91 print_error_analysis(&WARN_EDGE_CASE, "Edge case detected");
92}
93
94fn demonstrate_critical() {
95 println!("═══════════════════════════════════════════════════════════════");
96 println!(" CRITICAL (C): Severe issue requiring attention");
97 println!(" Data corruption, security breaches, memory leaks");
98 println!("═══════════════════════════════════════════════════════════════\n");
99
100 print_error_analysis(&CRIT_DATA_CORRUPT, "Data corruption detected");
101 print_error_analysis(&CRIT_SEC_BREACH, "Security breach identified");
102 print_error_analysis(&CRIT_MEM_LEAK, "Memory leak detected");
103}
104
105fn demonstrate_blocked() {
106 println!("═══════════════════════════════════════════════════════════════");
107 println!(" BLOCKED (B): Execution blocked/waiting");
108 println!(" Execution MUST halt - waiting for resource/resolution");
109 println!("═══════════════════════════════════════════════════════════════\n");
110
111 print_error_analysis(&BLOCK_DEADLOCK, "Deadlock detected between threads");
112 print_error_analysis(&BLOCK_IO_WAIT, "Waiting for I/O operation");
113 print_error_analysis(&BLOCK_NET_DOWN, "Network connection unavailable");
114}
115
116fn demonstrate_success() {
117 println!("═══════════════════════════════════════════════════════════════");
118 println!(" SUCCESS/COMPLETED (S/K): Positive Outcomes");
119 println!(" Operation succeeded, task finished - positive results");
120 println!("═══════════════════════════════════════════════════════════════\n");
121
122 print_error_analysis(&SUCCESS_BUILD, "Build completed successfully");
123 print_error_analysis(&SUCCESS_TEST, "All tests passed");
124 print_error_analysis(&COMPLETE_PARSE, "Parsing phase complete");
125 print_error_analysis(&COMPLETE_TYPECHECK, "Type checking complete");
126}
127
128fn demonstrate_info_trace() {
129 println!("═══════════════════════════════════════════════════════════════");
130 println!(" INFO/TRACE (I/T): Informational & Instrumentation");
131 println!(" Events, milestones, probes, execution traces");
132 println!("═══════════════════════════════════════════════════════════════\n");
133
134 print_error_analysis(&INFO_SERVER_START, "Server started successfully");
135 print_error_analysis(&INFO_CONFIG_LOAD, "Configuration loaded");
136 print_error_analysis(&TRACE_THREAD_SPAWN, "Thread T1 spawned at line 42");
137 print_error_analysis(&TRACE_LOCK_ACQUIRE, "Lock acquired by thread T1");
138}
139
140fn print_matrix_summary() {
141 println!("\n╔═══════════════════════════════════════════════════════════════╗");
142 println!("║ WADDLING SEVERITY LEVELS SUMMARY ║");
143 println!("╠═══════════╦═════════════════════════════════════════════════╣");
144 println!("║ Severity ║ Use Cases ║");
145 println!("╠═══════════╬═════════════════════════════════════════════════╣");
146 println!("║ Blocked(B)║ Deadlock, I/O wait, network down, resource lock ║");
147 println!("║Critical(C)║ Data loss, security breach, memory leaks ║");
148 println!("║ Error (E) ║ Invalid input, parse errors, auth failures ║");
149 println!("║ Warning(W)║ Deprecated API, performance concerns, edge cases║");
150 println!("║ Success(S)║ Operation succeeded ✅ ║");
151 println!("║Complete(K)║ Task/phase finished ✅ ║");
152 println!("║ Info (I) ║ Server start, config loaded, milestones ║");
153 println!("║ Trace (T) ║ Probes, execution traces, instrumentation ║");
154 println!("╚═══════════╩═════════════════════════════════════════════════╝\n");
155
156 println!("KEY FEATURES:");
157 println!("• All severity levels for complete diagnostic coverage");
158 println!("• .level() method returns 0-7 for ordering/filtering");
159 println!("• .is_positive() identifies Success/Completed outcomes");
160 println!("• Consistent [E.COMPONENT.PRIMARY.001] format");
161 println!("• Info for events/milestones, Trace for probes/instrumentation\n");
162}
163
164fn main() {
165 println!("\n");
166 println!("🦆 WADDLING SEVERITY LEVELS DEMONSTRATION 🦆");
167 println!("\n");
168
169 demonstrate_errors();
170 demonstrate_warnings();
171 demonstrate_critical();
172 demonstrate_blocked();
173 demonstrate_success();
174 demonstrate_info_trace();
175
176 print_matrix_summary();
177}