Skip to content

Conversation

@konstin
Copy link
Contributor

@konstin konstin commented May 23, 2025

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 #149

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
@konstin
Copy link
Contributor Author

konstin commented May 23, 2025

btw I had some trouble with my autoformatter as there are lines with trailing whitespace in the docstrings.

@LukeMathWalker
Copy link
Owner

The code looks OK, but we need some test coverage to merge and release this.

@konstin
Copy link
Contributor Author

konstin commented Jun 11, 2025

I've added two tests, one for io::Error, the case we're hitting in uv, and one with a custom error, to have that covered too.

@konstin
Copy link
Contributor Author

konstin commented Jun 11, 2025

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
@LukeMathWalker LukeMathWalker merged commit ba2e0c7 into LukeMathWalker:main Jun 19, 2025
4 of 5 checks passed
@LukeMathWalker
Copy link
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
````
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.

Simulate fault

2 participants