How to pass reqwest Result to a function?

If I make a request with reqwest, I get a reqwest::error::Result<Response>:

let client = reqwest::blocking::Client::new();
let result ="").send();

I want to pass this result to a function, which will then determine the course of action. It will take into account not only the received response but also whether a response was received at all, that's why I want to pass the Result, not just the Response.

I tried this:

fn error_action(api_call_result: reqwest::error::Result<Response>) -> ErrorType {


error[E0603]: module `error` is private
   --> src\
62  |     fn error_action(api_call_result: reqwest::error::Result<Response>) -> ErrorType {
    |                                               ^^^^^ private module

The Result alias appears to be exported from the crate root on v0.11.14. Did you try it without the error module in the path?


That's only for the async API I think?

error[E0308]: mismatched types
  --> src\
52 |         match Self::error_action(result) {
   |               ------------------ ^^^^^^ expected `reqwest::Response`, found `reqwest::blocking::Response`
   |               |
   |               arguments to this function are incorrect

That error is for the Response type, not the Result type. Did you import the blocking version of Response?

Oh, indeed, didn't see that.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.