Repository navigation
Commit f27bba7
committed
fix(client): reconstruct typed errors from the server's SQLSTATE
The native connection read a server error frame with `.map(|e| e.message)`,
keeping the message and dropping `e.code`, so every server-returned error
reached callers as `ErrorCode(9000)` / `ErrorDetails::Internal` regardless
of what the server had classified it as.
Every predicate on `NodeDbError` derives from `ErrorDetails`, so this also
broke classification rather than just the error text: a cross-shard OCC
abort is sent as `40001` specifically so the client retries it, and arrived
as a non-retriable internal fault.
Add `NodeDbError::from_sqlstate` beside the SQLSTATE constants so both
transports can use it, and route both call sites through it. It returns a
whole `NodeDbError` rather than a bare `ErrorDetails` because the struct's
fields are `pub(super)`, so the client cannot assemble one from parts, and
because it keeps `code` and `details` in lockstep the way every other
constructor does.
Mapping is conservative and the reasoning is recorded in the module doc:
payload fields are left empty rather than scraped out of the message,
codes overloaded across variants with different retriability are left
unmapped, and so are codes whose variant carries a load-bearing payload.
Anything unmapped falls through to `NodeDbError::internal`, which is what
every server error produced before, so unknown codes are no worse off.1 parent 2828760 commit f27bba7
3 files changed
Lines changed: 396 additions & 13 deletions
File tree
- nodedb-client/src/native/connection
- nodedb-types/src/error/ctors
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
17 | | - | |
18 | | - | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| |||
449 | 449 | | |
450 | 450 | | |
451 | 451 | | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
452 | 466 | | |
453 | 467 | | |
454 | | - | |
455 | | - | |
456 | | - | |
457 | | - | |
458 | | - | |
| 468 | + | |
459 | 469 | | |
460 | 470 | | |
461 | 471 | | |
462 | 472 | | |
463 | 473 | | |
464 | 474 | | |
465 | | - | |
466 | | - | |
467 | | - | |
468 | | - | |
469 | | - | |
| 475 | + | |
470 | 476 | | |
471 | 477 | | |
472 | 478 | | |
| |||
498 | 504 | | |
499 | 505 | | |
500 | 506 | | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
501 | 510 | | |
502 | 511 | | |
503 | 512 | | |
504 | 513 | | |
| 514 | + | |
505 | 515 | | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
506 | 568 | | |
507 | 569 | | |
508 | 570 | | |
| |||
0 commit comments