-
Notifications
You must be signed in to change notification settings - Fork 140
Add Iterator over causes of a Fail
#54
Add Iterator over causes of a Fail
#54
Conversation
Thanks for the PR! This was discussed in #41 and I'm mulling it over still. A big question I think is whether or not this should include self as the first cause. I am not certain that for cause in &err {
}
Lastly, a nit: I would prefer the name |
also implement `causes()` for `Error` where it will then return the cause of the `Error` as the first item
a6135a4
to
1f52184
Compare
I changed the name and also added a The The |
It's interesting how this one interacts with #65. I think it could be made possible to override |
Thanks for this PR, I've decided to merge it in 🎉 |
Thanks! |
What is the rationale for It seems surprising without reading the docs carefully. I personally would expect |
@epage It just seemed like it'd be what you want more often, and semantically more correct. There always is a root cause, if If you want the alternative behavior, you can instead do: let root_cause = err.cause().map(|_| err.root_cause()); |
That makes sense for generally asking the question "what is the root cause" but it feels like it breaks down to me when put in the context of the API. The question is now "What is the root cause for this I know its easy to transform the answers that API gives between different forms. I just want to help ensure that the API is polished, including minimizing surprises. For me, I found the current behavior surprising; maybe thats not the case for everyone. Feel free to move along if you disagree; at least its now recorded in case others ask the question. |
this way you can look if a
Fail
contains e.g. an io::Error like thisor even