Commit e735e40
authored
refactor: eliminate all unwrap() calls from Rust codebase (#28)
Replace all unwrap() calls with proper error handling:
- Use expect() with descriptive messages for programmer errors
- Use unwrap_or_else() for graceful fallbacks
- Proper error handling in metrics encoder
Changes:
- Prometheus metrics: unwrap() → expect() (6 instances)
- Health serialization: unwrap() → unwrap_or_else() with JSON fallback (36 instances)
- Metrics encoder: unwrap() → match with HTTP 500 error response (1 instance)
- MongoDB field access: improved default values (8 instances)
- Test assertions: unwrap() → expect() with descriptive messages (4 instances)
All 44 tests pass successfully.
Total unwrap() calls eliminated: 55 (51 from main.rs, 4 from tests.rs)1 parent 9ec5492 commit e735e40
File tree
5 files changed
+1474
-85
lines changed- docs
- reference-apps/rust
- src
- tests
5 files changed
+1474
-85
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
66 | 74 | | |
67 | 75 | | |
68 | 76 | | |
| |||
293 | 301 | | |
294 | 302 | | |
295 | 303 | | |
296 | | - | |
| 304 | + | |
297 | 305 | | |
298 | 306 | | |
299 | 307 | | |
300 | 308 | | |
301 | 309 | | |
302 | 310 | | |
303 | 311 | | |
304 | | - | |
| 312 | + | |
305 | 313 | | |
306 | 314 | | |
307 | 315 | | |
| |||
0 commit comments