Commit 6fa2c7d
Map reqwest errors to semantically correct Twirp error codes (#314)
* Map reqwest errors to semantically correct Twirp error codes
Replace the blanket From<reqwest::Error> → InvalidArgument mapping with
variant-specific logic:
- is_builder() → InvalidArgument (actually bad input)
- is_redirect() / is_body() / is_decode() → Internal (unexpected behavior)
- everything else (connect, timeout, request) → Unavailable (transient)
This lets downstream consumers distinguish transport failures from
application errors, enabling correct retry decisions.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Hoist .with_rust_error(e) out of branches
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Address review feedback on reqwest error mapping tests
- Use localhost TcpListener instead of non-routable IP for timeout test
- Fix misleading comment on builder error test
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 5b756cd commit 6fa2c7d
1 file changed
Lines changed: 50 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
258 | 258 | | |
259 | 259 | | |
260 | 260 | | |
261 | | - | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
262 | 265 | | |
263 | 266 | | |
264 | | - | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
265 | 277 | | |
266 | 278 | | |
267 | 279 | | |
| |||
393 | 405 | | |
394 | 406 | | |
395 | 407 | | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
396 | 444 | | |
397 | 445 | | |
398 | 446 | | |
| |||
0 commit comments