diff --git a/src/main.rs b/src/main.rs index 27031bf..36966d3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -79,7 +79,15 @@ async fn main() -> Result<(), Box> { sth = &sth[segment]; } } - let res_value = sth.as_f64().unwrap_or(0.0); + + let mut res_value = sth.as_f64().unwrap_or(0.0); + if sth.is_string() { + res_value = match sth.as_str().unwrap().parse::() { + Ok(val) => val, + Err(_) => panic!("Conversion error on {}", sth) + }; + } + let system = value["tags"]["system"].as_str().unwrap().to_string(); let metric = value["tags"]["metric"].as_str().unwrap().to_string(); let unit = value["tags"]["unit"].as_str().unwrap().to_string(); @@ -110,7 +118,7 @@ async fn main() -> Result<(), Box> { let write_result = client .query(write_queries) .await; - assert!(write_result.is_ok(), "Write result was not okay"); + assert!(write_result.is_ok(), "{}", write_result.err().unwrap().to_string()); Ok(()) }