Allow returning arbitrary errors#159
Merged
LukeMathWalker merged 3 commits intoLukeMathWalker:mainfrom Jun 19, 2025
Merged
Conversation
Add `MockBuilder::respond_with_err` to respond with an arbitrary Rust error instead of an HTTP error. Due to overlapping impl constraints, `RespondErr` only supports passing a function that returns an error and not the error itself. Fixes LukeMathWalker#149
Contributor
Author
|
btw I had some trouble with my autoformatter as there are lines with trailing whitespace in the docstrings. |
Owner
|
The code looks OK, but we need some test coverage to merge and release this. |
Contributor
Author
|
I've added two tests, one for |
Contributor
Author
|
The main reqwest error diverges between my machine and CI, I've now changed it to only look at the error source chain. |
konstin
added a commit
to astral-sh/uv
that referenced
this pull request
Jun 13, 2025
Often, HTTP requests don't fail due to server errors, but from spurious network errors such as connection resets. reqwest surfaces these as `io::Error`, and we have to handle their retrying separately. Companion PR: LukeMathWalker/wiremock-rs#159
Owner
|
Released in 0.6.4, thanks! |
konstin
pushed a commit
to astral-sh/uv
that referenced
this pull request
Jun 24, 2025
<!-- Thank you for contributing to uv! To help us out with reviewing, please consider the following: - Does this pull request include a summary of the change? (See below.) - Does this pull request include a descriptive title? - Does this pull request include references to any relevant issues? --> ## Summary In e10881d, `uv` started using a fork of the `wiremock` crate, https://github.com/astral-sh/wiremock-rs, linking companion PR LukeMathWalker/wiremock-rs#159. That PR was merged in `wiremock` 0.6.4, so this PR switches back to the crates.io version of `wiremock`, with a minimum version of 0.6.4. <!-- What's the purpose of the change? What does it do, and why? --> ## Test Plan ``` $ cargo run python install $ cargo test ````
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add
MockBuilder::respond_with_errto respond with an arbitrary Rust error instead of an HTTP error.Due to overlapping impl constraints,
RespondErronly supports passing a function that returns an error and not the error itself.Fixes #149