-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Display chained errors #43
Comments
Excellent! That is really nice Nikolaus. Let me look into how to get at the data in the inner error messages. Please let me know if you have thoughts about how the approach modifications on the ufofmt side. I would like to support this. |
Hm, I think it is basically about recursively calling source() on the errors until you get None and print the messages of all, but maybe looking at the anyhow source code is more enlightening. |
Is the example that yielded the error in your OP:
in the norad repo? |
Note to self: https://docs.rs/anyhow/1.0.51/anyhow/struct.Error.html#display-representations I don't have a problem with simply adding anyhow error handling in this project. It looks like we get the recursive calls handled with that library. |
I modified the UFO in question to end a |
https://www.lpalmieri.com/posts/error-handling-rust/ contains an example on how to print error sources: //! src/routes/subscriptions.rs
// [...]
fn error_chain_fmt(
e: &impl std::error::Error,
f: &mut std::fmt::Formatter<'_>,
) -> std::fmt::Result {
writeln!(f, "{}\n", e)?;
let mut current = e.source();
while let Some(cause) = current {
writeln!(f, "Caused by:\n\t{}", cause)?;
current = cause.source();
}
Ok(())
} |
Thanks Nikolaus! Let's see if #44 addresses this. I'll prepare test sources to have a look at the output format from chained norad errors. |
Cool :) it might also be an opportunity to review the error hierarchy, as in, do the errors tell you what you need to know. See https://kazlauskas.me/entries/errors |
sg! |
Hmm. It looks like there was a big refactor in error types and now I can't build the branch in #44 based on norad master branch. |
Sorted out in e4948b07ce088ad957c35fad9f125a402704094b |
Looking good! Here's what I see in the #44 branch if I mangle a cap
and when I remove the
|
I'm trying to make norad cleanly chain errors instead of hoisting the error messages form lower into wrapping error messages. Compare what
anyhow
does:vs. ufofmt's
The text was updated successfully, but these errors were encountered: