Commit 8d0679e
authored
refactor(facade): migrate all facade APIs from throw to Result<T> (#952)
* refactor(facade): migrate all facade APIs from throw to Result<T>
Replace 30 throw statements across 5 facade files with Result<T>
return values, unifying error handling with the ecosystem convention.
Changes per facade (tcp, quic, udp, websocket, http):
- validate_* return type: void -> VoidResult
- create_client/create_server return type: shared_ptr -> Result<shared_ptr>
- create_connection_pool return type: shared_ptr -> Result<shared_ptr>
- throw std::invalid_argument -> return error_void(-1, msg, source)
- throw std::runtime_error -> return error<T>(code, msg, source)
- Success paths: return ptr -> return ok(ptr)
Also fix broken markdown anchors in docs TOC files.
Closes #951
* test(facade): update facade tests for Result<T> return types
Migrate all facade test assertions from exception-based to Result-based:
- EXPECT_THROW -> result.is_err()
- EXPECT_NO_THROW(var = ...) -> ASSERT_TRUE(result.is_ok()); var = result.value()
- Direct assignment -> result check + value extraction
* fix(test): resolve conflicting 'auto result' redeclaration in test scopes
Rename second 'auto result' to 'send_result' or 'stop_result' in
tests where create_* result and interface method result share scope.
* fix(benchmarks): unwrap Result<T> from facade create methods
facade create_client() and create_server() now return Result<shared_ptr<T>>
instead of shared_ptr<T>. Update all call sites in the benchmark file to
unwrap the Result with .value() before using the pointer.
* fix(tests): update facade tests for Result<T> return types
Facade create methods now return Result<shared_ptr<T>> instead of
throwing exceptions or returning raw pointers. Update tests to:
- Use .is_ok() and .value() to unwrap Result before nullptr checks
- Replace EXPECT_THROW(invalid_argument) with is_err() assertions
for port validation tests across TCP, UDP, HTTP, WebSocket, and
QUIC facades
* fix(tests): suppress nodiscard warnings for VoidResult in e2e tests
start_server(), stop_server(), start_client(), stop_client(), and
send_packet() now return [[nodiscard]] VoidResult. Cast all call sites
to (void) to suppress -Werror=unused-result warnings.
* docs(facade): update guide for Result<T> return types
Update all facade code examples and API signatures to reflect the
migration from throw-based to Result<T> return types in create_client(),
create_server(), and create_connection_pool() methods.1 parent 789fb72 commit 8d0679e
22 files changed
Lines changed: 743 additions & 430 deletions
File tree
- benchmarks
- docs
- facades
- include/kcenon/network/facade
- src/facade
- tests
- integration
- unit
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
138 | 138 | | |
139 | 139 | | |
140 | 140 | | |
141 | | - | |
| 141 | + | |
142 | 142 | | |
143 | 143 | | |
144 | 144 | | |
145 | 145 | | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
146 | 151 | | |
147 | 152 | | |
148 | 153 | | |
| |||
188 | 193 | | |
189 | 194 | | |
190 | 195 | | |
191 | | - | |
| 196 | + | |
192 | 197 | | |
193 | 198 | | |
194 | 199 | | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
195 | 205 | | |
196 | 206 | | |
197 | 207 | | |
| |||
342 | 352 | | |
343 | 353 | | |
344 | 354 | | |
345 | | - | |
| 355 | + | |
346 | 356 | | |
347 | 357 | | |
348 | 358 | | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
349 | 365 | | |
350 | 366 | | |
351 | 367 | | |
| |||
357 | 373 | | |
358 | 374 | | |
359 | 375 | | |
360 | | - | |
| 376 | + | |
361 | 377 | | |
362 | 378 | | |
363 | 379 | | |
364 | 380 | | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
365 | 388 | | |
366 | 389 | | |
367 | 390 | | |
| |||
638 | 661 | | |
639 | 662 | | |
640 | 663 | | |
641 | | - | |
| 664 | + | |
642 | 665 | | |
643 | 666 | | |
644 | 667 | | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
645 | 674 | | |
646 | 675 | | |
647 | 676 | | |
| |||
664 | 693 | | |
665 | 694 | | |
666 | 695 | | |
667 | | - | |
| 696 | + | |
668 | 697 | | |
669 | 698 | | |
670 | 699 | | |
671 | 700 | | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
672 | 706 | | |
673 | 707 | | |
674 | 708 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| |||
0 commit comments