@@ -132,13 +132,24 @@ impl Error {
132
132
self . as_fail ( ) . find_root_cause ( )
133
133
}
134
134
135
- /// Returns a iterator over the causes of the `Error`, beginning with
136
- /// the failure returned by the `as_fail` method and ending with the failure
137
- /// returned by `find_root_cause`.
135
+ /// Returns a iterator over the causes of this error with the cause
136
+ /// of the fail as the first item and the `root_cause` as the final item.
137
+ ///
138
+ /// Use `iter_chain` to also include the fail of this error itself.
138
139
pub fn iter_causes ( & self ) -> Causes {
139
140
self . as_fail ( ) . iter_causes ( )
140
141
}
141
142
143
+ /// Returns a iterator over all fails up the chain from the current
144
+ /// as the first item up to the `root_cause` as the final item.
145
+ ///
146
+ /// This means that the chain also includes the fail itself which
147
+ /// means that it does *not* start with `cause`. To skip the outermost
148
+ /// fail use `iter_causes` instead.
149
+ pub fn iter_chain ( & self ) -> Causes {
150
+ self . as_fail ( ) . iter_chain ( )
151
+ }
152
+
142
153
/// Attempts to downcast this `Error` to a particular `Fail` type by
143
154
/// reference.
144
155
///
@@ -162,7 +173,7 @@ impl Error {
162
173
}
163
174
164
175
/// Deprecated alias to `iter_causes`.
165
- #[ deprecated( since = "0.1.2" , note = "please use the 'iter_causes ()' method instead" ) ]
176
+ #[ deprecated( since = "0.1.2" , note = "please use the 'iter_chain ()' method instead" ) ]
166
177
pub fn causes ( & self ) -> Causes {
167
178
Causes { fail : Some ( self . as_fail ( ) ) }
168
179
}
0 commit comments