Skip to content

style: simplify internal error variants - #286

Merged
FalkWoldmann merged 2 commits into
httpmock:masterfrom
danieleades:agent/clippy-enum-variant-names
Aug 16, 2026
Merged

FalkWoldmann merged 2 commits into
httpmock:masterfrom
danieleades:agent/clippy-enum-variant-names

Conversation

@danieleades

@danieleades danieleades commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

What changed

  • remove eight internal error variants that were never constructed
  • name the remaining variants after the operation that failed instead of repeating Error, giving RequestSend, ResponseBodyRead, TaskJoin, MissingParam, ResponseBodyConstruction and so on
  • keep the typed source errors, using #[from] where the mapping is unambiguous
  • report static mock directory and file failures with their paths instead of panicking
  • deserialize static mock definitions directly so the YAML parser's locations survive
  • remove clippy::enum_variant_names from the temporary allow list

Why

Names like RequestConversionError and FileReadError repeat what Error::... already says. A straight rename would have kept the dead variants and the implementation-oriented names along with them, so this drops the variants with no construction path and names the rest after what failed. Both the matches and the messages read better for it.

#[from] is limited to the unambiguous mappings: YAML, state, and data conversion. Operation-dependent errors stay explicitly mapped so they keep their context. Static mock I/O errors keep the path, which also removes two panics.

Compatibility

Not source-breaking downstream. The affected enums live in private modules and server::Error is unchanged. Diagnostics and debug output read better, and a bad static mock path now returns an error instead of panicking.

Validation

  • cargo +stable clippy --all-targets --all-features
  • cargo +stable clippy --all-targets --no-default-features
  • cargo +stable test --all-features --lib
  • cargo +stable fmt --all -- --check
  • git diff --check

@codecov

codecov Bot commented Aug 12, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 50.00000% with 18 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/server/persistence.rs 17.64% 14 Missing ⚠️
src/common/data.rs 77.77% 2 Missing ⚠️
src/server/handler.rs 80.00% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

@danieleades
danieleades marked this pull request as ready for review August 12, 2026 19:25
@FalkWoldmann
FalkWoldmann merged commit 904fc03 into httpmock:master Aug 16, 2026
11 of 12 checks passed
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.

2 participants