Skip to content

refactor: log context for errors instead of discarding them - #329

Open
blind-dev-azhasys wants to merge 2 commits into
linux-credentials:masterfrom
blind-dev-azhasys:refactor/ble-let-else-errors
Open

blind-dev-azhasys wants to merge 2 commits into
linux-credentials:masterfrom
blind-dev-azhasys:refactor/ble-let-else-errors

Conversation

@blind-dev-azhasys

Copy link
Copy Markdown

Log context for transport/protocol errors instead of discarding them

Part of #14.

What

Replaces the .or(Err(...))? error-handling pattern, which silently
discarded the underlying error, with forms that record context using
tracing before returning the typed error — following the approach
suggested in #14:

  • btleplug BLE transport (manager.rs, connection.rs): every
    Result-returning btleplug call (adapter events, scans, peripheral
    connect/discover/read/write, notification subscription, GATT UUID
    parsing) now logs the underlying btleplug error with error! before
    returning Error::{Unavailable,ConnectionFailed,OperationFailed,InvalidFraming}.
  • pxp (pxp/src/ble.rs, pxp/src/protocol.rs): BLE discovery and CTAP
    response forwarding log before returning PxpError.
  • ctap1 (proto/ctap1/protocol.rs): APDU status/response parsing and
    the user-presence wait now log before returning CtapError::Other /
    UserActionTimeout.
  • Parsing sites (ctap1/model.rs, ctap1/apdu/response.rs,
    ble/framing.rs): switched from .or(Err(IOError::new(...))) to
    .map_err(...) so the original error is included in the IOError
    message instead of being dropped.

No behavioral changes beyond logging and richer IOError messages; all
returned error variants are unchanged.

Validation

  • cargo clippy --workspace --all-features: clean (only pre-existing
    manifest warnings about unused dev-dependencies).
  • cargo fmt: clean.
  • cargo test --workspace: all tests pass (544 in libwebauthn plus
    pxp/libwebauthn-tests suites).

… them

Replace .or(Err(...))? patterns in the btleplug manager and connection
with match/let-else statements that record the underlying error with
tracing before returning the typed Error, so failures are traceable.

Part of linux-credentials#14.
Replace remaining .or(Err(...))? patterns: pxp BLE discovery and CTAP
response forwarding now log with tracing before returning; ctap1 parsing
sites use map_err so the original error is included in the IOError.

Part of linux-credentials#14.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant