Question about reqwest

I have a question regarding the reqwest crate. Maybe someone knows it better than I do.
I try to download a file, but it occasionally fails.
This is what my code looks like for downloading:

let mut tries = 0;
while tries < 5 {
    let mut resp = reqwest::get(page);
    match resp {
        Err(e) => {
            tries += 1;
            if tries == 6 {
         Ok(_) => tries = 5,

I usually count down retries left to 0.

You can wrap it in a function to use return Err(e) and return Ok(response) instead of having to call exit directly.

could you show me how? still not that good with rust, and the match statements confuse me a lot.

Well it seems your code can never process::exit(1). To enter the if tries == 6 block, tries should be 5 at the start of the iteration, which is not possible as it will escape the while tries < 5 condition.

1 Like

hm... that's true. Now that you said it I see it aswell