SIGN IN SIGN UP

errors: typed server-rejection variant — Error::Message → Error::Notice(Notice) (#591)

* errors: Error::Message → Error::Notice(Notice) typed rejection variant

TWS-emitted error frames now arrive as Error::Notice(Notice) on
Result<_, Error> returns, replacing Error::Message(i32, String).
The new variant carries the full typed Notice — code, message,
error_time, advanced_order_reject_json — and exposes the same
classification API as the streaming side (Notice::category /
is_order_rejection / is_warning).

Symmetric with SubscriptionItem::Notice(Notice). Distinct from
Error::ConnectionRejected (handshake-time refusal) and the
transport variants (Error::Io, Error::ConnectionReset).

From<ResponseMessage> and From<DecodedError> absorb the variant
change; the 25 dispatcher/decoder call sites that emit
Err(Error::from(message)) need no edits. As a bonus, the
projection now preserves error_time and advanced_order_reject_json
that the old Error::Message tuple dropped.

Plan: plans/typed-rejection-error.md
Migration: docs/migration-3.0.md
Parent tracker: plans/v3-api-ergonomics.md §5.2

* docs(plans): mark v3-ergonomics §5.2 shipped (#591)

* errors: collapse 7 test-construction sites via tws_error_notice helper

Pure /simplify follow-up. Adds `helpers::tws_error_notice(code, message)`
in `src/common/test_utils.rs` and routes the 7 callers that built
`Error::Notice(Notice::synthesized(code, msg))` through it:

- src/errors_tests.rs × 2
- src/common/test_utils_tests.rs × 3
- src/client/error_handler/tests.rs × 2

Helper is test-only (gated `#[cfg(test)]` via `common::test_utils`); no
new surface on `impl Error` since production never constructs synthetic
notices — the wire path is `From<ResponseMessage> for Error`.

Net −7 chars per callsite; removes the `crate::messages::Notice::synthesized`
qualifier from every test site and makes the construction intent
("Result-path Error from a synthesized TWS notice") obvious at a glance.
W
Wil Boayue committed
4ac646703bec09e556858e47b2ddd85360a48651
Parent: 2aede92
Committed by GitHub <noreply@github.com> on 5/19/2026, 6:19:07 PM