Skip to content

Implement WireframeError error integration (#513)#528

Draft
leynos wants to merge 1 commit into
mainfrom
issue-513-wireframeerror-e-should-derive-display-and-std-error-error
Draft

Implement WireframeError error integration (#513)#528
leynos wants to merge 1 commit into
mainfrom
issue-513-wireframeerror-e-should-derive-display-and-std-error-error

Conversation

@leynos
Copy link
Copy Markdown
Owner

@leynos leynos commented May 20, 2026

Summary

This branch implements standard error integration for WireframeError in support of issue #513. It makes the default public error type usable through std::error::Error, preserves source chaining for transport and codec failures, and lets TestError use thiserror's transparent #[from] conversion.

Closes #513.

Review walkthrough

  • Start with src/error.rs to review the std::error::Error implementation and source chaining behaviour.
  • Then review src/testkit/result.rs for the transparent TestError::Wireframe conversion.
  • Finish with tests/error_display.rs for the coverage around WireframeError<()> sources.

Validation

  • make check-fmt: passed
  • make lint: passed
  • make test: passed
  • coderabbit review --agent: passed with zero findings after one rate-limit retry

Notes

The originally suggested blanket Display/Error implementation plus a separate WireframeError<()> specialisation conflicts under Rust's coherence rules because upstream crates may add future trait implementations for (). This branch therefore uses a stable-compatible Error implementation for WireframeError<E> where E: Debug + 'static; source() exposes the nested Io and Codec errors that are always known to implement Error.

Summary by Sourcery

Integrate WireframeError with the standard error trait and tighten how error sources are exposed.

New Features:

  • Allow WireframeError to be used as a std::error::Error without requiring the inner error type to implement Error.
  • Support transparent conversion from WireframeError into TestError via thiserror's #[from] attribute.

Enhancements:

  • Restrict WireframeError::source to expose only I/O and codec errors as underlying sources, treating protocol and duplicate-route variants as source-less.
  • Extend tests to cover WireframeError<()> Error behavior and refine expectations around which variants expose error sources.

Tests:

  • Add coverage to validate std::error::Error implementation for WireframeError<(),> including source preservation for I/O and codec errors and absence of sources for protocol and duplicate-route variants.

Implement `std::error::Error` for `WireframeError` so the default
public error type can participate in standard error handling. Preserve
transport and codec sources, and keep protocol variants source-free on
stable Rust because the requested blanket-plus-unit specialization
conflicts under coherence rules.

Use thiserror's transparent `#[from]` conversion in `TestError` now
that `WireframeError<()>` implements `Error`.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 20, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: ef9c0da3-75c5-4dbe-9e7a-c220cfd314fa

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch issue-513-wireframeerror-e-should-derive-display-and-std-error-error

Comment @coderabbitai help to get the list of available commands and usage tips.

@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai Bot commented May 20, 2026

Reviewer's Guide

Integrates WireframeError with std::error::Error in a coherence-safe way, exposes only IO and codec errors as sources, and simplifies TestError by using thiserror’s transparent #[from] conversion, with tests updated to cover the new Error behavior for WireframeError and WireframeError<()> specifically.

File-Level Changes

Change Details Files
Adjust WireframeError’s std::error::Error implementation to relax trait bounds and refine which variants expose error sources.
  • Change Error impl bound on WireframeError from requiring E: Debug + Error + 'static to only E: Debug + 'static for stability and coherence with potential upstream implementations.
  • Update source() to return Some(...) only for Io and Codec variants while returning None for Protocol and DuplicateRoute, ensuring consistent and specialization-free source exposure.
src/error.rs
Leverage thiserror’s transparent conversion for TestError::Wireframe and remove the manual From implementation.
  • Change TestError::Wireframe variant to #[error(transparent)] and accept #[from] WireframeError so TestError can be constructed from WireframeError via derive-generated conversion.
  • Remove the now-redundant manual impl From for TestError.
  • Keep existing conversions like From<&str> and mpsc::SendError unchanged.
src/testkit/result.rs
Update and extend tests to reflect new WireframeError Error behavior and to validate Error implementation for WireframeError<()> specifically.
  • Modify wireframe_error_messages test so Protocol variants are expected not to expose a source, aligning with the new Error implementation.
  • Add wireframe_error_unit_implements_error test to assert that WireframeError<()> implements Error, preserves sources for Io and Codec variants via downcasting, and does not expose sources for Protocol or DuplicateRoute.
  • Retain and rely on existing tests like wireframe_error_exposes_sources_for_io_and_codec to ensure Io and Codec source chaining behavior remains correct.
tests/error_display.rs

Assessment against linked issues

Issue Objective Addressed Explanation
#513 Ensure WireframeError implements Display with meaningful messages for all variants so it can be converted to user-facing strings.
#513 Ensure WireframeError implements std::error::Error (including for the default WireframeError<()>) so it participates in the standard error ecosystem and exposes appropriate sources for underlying IO/codec errors.
#513 Update TestError to use thiserror’s transparent #[from] conversion for WireframeError instead of a manual From impl.

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

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.

WireframeError<E> should derive Display and std::error::Error

1 participant