Closed nim65s closed 11 months ago
done, thanks for the review
@msrd0 : The point of this PR is to display a more precise error message to the end user, so we need to display {e}
or something similar.
ie. to go from something like "Write result was not okay" to something like "Write result was not okay, because your user is not authorized". I don't think we can do this with .expect()
.
Alternatively, we could have main()
returning a Result<(), influxdb::Error>
, and use ?
in read and write.
Is the difference between display and debug this big? I just looked it up, and expect("msg") is the same as unwrap_or_else(|e| panic!("msg: {e:?}")). I think given that this code is an example and has no intention to have "perfect" error handling, I'd go with either expect or unwrap and panic.
While your code outputs a nice error message to the terminal and exits, I think it is a bit more verbose than necessary for an example, and it needs a bit longer for a human to detect it as error-handling code. But I believe examples should be as concise as possible.
Using ? is also a good idea
Now I get Error: AuthorizationError
, which is good enough for me to understand that I need to setup auth :)
Ok, I was wrong about the use of msg
in expect()
, thanks for the clarification. I'm open to use that too, as you prefer.
Description
Hi,
Building the example in the README raise the following warning:
And running it for me shows:
which is not super helpful.
With the proposed changes, I get:
which is more clear :)
Checklist
cargo fmt --all
cargo clippy --manifest-path influxdb/Cargo.toml --all-targets --no-default-features --features use-serde,derive,reqwest-client -- -D warnings
cargo clippy --manifest-path influxdb/Cargo.toml --all-targets --no-default-features --features use-serde,derive,hyper-client -- -D warnings
cargo doc2readme -p influxdb --expand-macros