From: Greg Burri Date: Thu, 15 Jul 2021 14:10:51 +0000 (+0200) Subject: Include 'url' in error message X-Git-Url: https://git.euphorik.ch/?a=commitdiff_plain;h=99c5a6de3ef69a61dcff181bb4b11fc4141e3c81;p=gandi_dns_update.git Include 'url' in error message --- diff --git a/src/main.rs b/src/main.rs index cd54e9d..496fd98 100644 --- a/src/main.rs +++ b/src/main.rs @@ -31,7 +31,7 @@ fn main() -> Result<()> { let time_beginning_loop = time::Instant::now(); if let Err(err) = check_and_update_dns(&config.api_key, &config.fqdn, &config.domains, config.ttl) { - println!("!! Error: {}", err); + println!("!! {}", err); } let elapsed = time::Instant::now() - time_beginning_loop; @@ -72,11 +72,11 @@ fn get_real_ip() -> Result { _ => Err(Box::new(Error { message: String::from("Can't parse IPv4 from ipify") })) } } else { - Err(Box::new(Error { message: format!("Request unsuccessful: {:#?}", resp) })) + Err(Box::new(Error { message: format!("Request unsuccessful to {}: {:#?}", url, resp) })) }, Err(error) => { - Err(Box::new(Error { message: format!("Error during request: {:?}", error) })) + Err(Box::new(Error { message: format!("Error during request to {}: {:?}", url, error) })) } } } @@ -119,8 +119,8 @@ fn request_livedns_gandi(api_key: &str, url_fragment: &str, method: Method) -> R let request_builder = match method { - Method::Put(body) => client.put(url).body(body), - Method::Get => client.get(url) + Method::Put(body) => client.put(&url).body(body), + Method::Get => client.get(&url) }; match request_builder.header("Authorization", format!("Apikey {}", api_key)).send() { @@ -129,9 +129,9 @@ fn request_livedns_gandi(api_key: &str, url_fragment: &str, method: Method) -> R let content = resp.text().unwrap(); Ok(serde_json::from_str(&content).unwrap()) } else { - Err(Box::new(Error { message: format!("Request unsuccessful: {:#?}", resp) })) + Err(Box::new(Error { message: format!("Request unsuccessful to {}: {:#?}", &url, resp) })) }, Err(error) => - Err(Box::new(Error { message: format!("Error during request: {:?}", error) })) + Err(Box::new(Error { message: format!("Error during request to {}: {:?}", &url, error) })) } }