Skip to content

Commit 9660dd5

Browse files
committed
README: display clear errors in the example
1 parent 1c6661e commit 9660dd5

File tree

2 files changed

+17
-15
lines changed

2 files changed

+17
-15
lines changed

README.md

+9-8
Original file line numberDiff line numberDiff line change
@@ -93,17 +93,18 @@ async fn main() {
9393
}.into_query("weather"),
9494
);
9595

96-
let write_result = client
97-
.query(weather_readings)
98-
.await;
99-
assert!(write_result.is_ok(), "Write result was not okay");
96+
if let Err(e) = client.query(weather_readings).await {
97+
println!("Error writing result: {e}");
98+
return;
99+
}
100100

101101
// Let's see if the data we wrote is there
102102
let read_query = ReadQuery::new("SELECT * FROM weather");
103103

104-
let read_result = client.query(read_query).await;
105-
assert!(read_result.is_ok(), "Read result was not ok");
106-
println!("{}", read_result.unwrap());
104+
match client.query(read_query).await {
105+
Ok(read_result) => println!("{}", read_result),
106+
Err(e) => println!("Error reading result: {e}"),
107+
}
107108
}
108109
```
109110

@@ -167,7 +168,7 @@ To communicate with InfluxDB, you can choose the HTTP backend to be used configu
167168
@ 2020 Gero Gerke and [contributors].
168169

169170
[contributors]: https://github.com/influxdb-rs/influxdb-rust/graphs/contributors
170-
[__cargo_doc2readme_dependencies_info]: ggGkYW0BYXSEG64av5CnNoNoGw8lPMr2b0MoG44uU0T70vGSG7osgcbjN7SoYXKEG1WEE9zY5dHaG_H-oHwVY518G_Hz3Ch_FlkHG6679elOy6u-YWSBgmhpbmZsdXhkYmUwLjcuMQ
171+
[__cargo_doc2readme_dependencies_info]: ggGkYW0BYXSEG64av5CnNoNoGw8lPMr2b0MoG44uU0T70vGSG7osgcbjN7SoYXKEG_D2JHss1jsUG6eXkB7MmDoIG9miwB7MgvlwG_-cxCbQ3T7bYWSBgmhpbmZsdXhkYmUwLjcuMQ
171172
[__link0]: https://github.com/influxdb-rs/influxdb-rust/blob/main/CONTRIBUTING.md
172173
[__link1]: https://github.com/influxdb-rs/influxdb-rust/blob/main/CODE_OF_CONDUCT.md
173174
[__link10]: https://curl.se/libcurl/

influxdb/src/lib.rs

+8-7
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,18 @@
5656
//! }.into_query("weather"),
5757
//! );
5858
//!
59-
//! let write_result = client
60-
//! .query(weather_readings)
61-
//! .await;
62-
//! assert!(write_result.is_ok(), "Write result was not okay");
59+
//! if let Err(e) = client.query(weather_readings).await {
60+
//! println!("Error writing result: {e}");
61+
//! return;
62+
//! }
6363
//!
6464
//! // Let's see if the data we wrote is there
6565
//! let read_query = ReadQuery::new("SELECT * FROM weather");
6666
//!
67-
//! let read_result = client.query(read_query).await;
68-
//! assert!(read_result.is_ok(), "Read result was not ok");
69-
//! println!("{}", read_result.unwrap());
67+
//! match client.query(read_query).await {
68+
//! Ok(read_result) => println!("{}", read_result),
69+
//! Err(e) => println!("Error reading result: {e}"),
70+
//! }
7071
//! }
7172
//! ```
7273
//!

0 commit comments

Comments
 (0)