Closed ShayBox closed 1 year ago
Unrelated, but you should use the log
or tracing
crates to print info/warn/error messages instead of prepending [WARN]
so the final binary programs can subscribe/filter/modify the logs of libraries.
Thanks for letting me know! I agree that we need better logging. I will add the pretty_env_logger or just the log crate and more log entries because it's a good way to catch errors.
Regarding error types, I'm not sure if we should have strict error types or not, but we definitely need to change the type I used
I'm not too familiar with the log
/env_logger
/pretty_env_logger
family of crates, as I use tracing
/tracing_subscriber
crates.
I assume env_logger
/pretty_env_logger
(tracing_subscriber
) is meant to be used in the binary to configure logging, while log
(tracing
) is meant to be used in both to do the logging.
I usually use anyhow
for everything, unless I think there's a need for multiple error types.
If there's a method that can error for multiple reasons and if there's a good chance the end user might need to know the difference for behavior or if they just need to know Ok
/Err
Hi
I changed all the errors to throw Result of anyhow
, and also added logging using log
.
Can you try it before I publish?
You can add it to Cargo.toml
and add the latest code this way:
[dependencies]
rookie = { git = "https://github.com/thewh1teagle/rookie" }
It works!
Great! added to latest version.
Describe the feature
Currently the
Error
type used isBox<dyn Error>
which cannot be known at compilation time, which prevents using the?
operator within a method that returnsResult
.Using a crate such as
thiserror
or evenanyhow
if you'd rather not have strict Error types would solve this and make using this library easier.