With rust 1.49 and reqwest 0.11.0, i would like to retrieve a URL, and react on possible errors (wrong URL, no network, ...).
My (simplifed) base code is (and this is working) :
async fn test_url() -> Result<(), reqwest::Error> {
let response = reqwest::get("https://aaaaa.bbb").await?;
info!("Status : {}", response.status());
}
How to handle the possible errors ?
If i try to add something like this
match response.error_for_status_ref() {
Ok(_) => {
info!("Status: {}", response.status());
},
Err(err) => {
error!("Error {}", err);
},
}
Then it doesn't work (my code is not executed, like if reqwest is throwing a panic ?).