@@ -125,10 +125,18 @@ impl Error {
125
125
pub fn downcast < T : Fail > ( self ) -> Result < T , Error > {
126
126
self . imp . downcast ( ) . map_err ( |imp| Error { imp } )
127
127
}
128
+
128
129
/// Returns the "root cause" of this error - the last value in the
129
130
/// cause chain which does not return an underlying `cause`.
130
- pub fn root_cause ( & self ) -> & Fail {
131
- :: find_root_cause ( self . as_fail ( ) )
131
+ pub fn find_root_cause ( & self ) -> & Fail {
132
+ self . as_fail ( ) . find_root_cause ( )
133
+ }
134
+
135
+ /// Returns a iterator over the causes of the `Error`, beginning with
136
+ /// the failure returned by the `cause` method and ending with the failure
137
+ /// returned by `find_root_cause`.
138
+ pub fn iter_causes ( & self ) -> Causes {
139
+ self . as_fail ( ) . iter_causes ( )
132
140
}
133
141
134
142
/// Attempts to downcast this `Error` to a particular `Fail` type by
@@ -147,9 +155,14 @@ impl Error {
147
155
self . imp . failure_mut ( ) . downcast_mut ( )
148
156
}
149
157
150
- /// Returns a iterator over the causes of the `Error`, beginning with
151
- /// the failure returned by the `cause` method and ending with the failure
152
- /// returned by `root_cause`.
158
+ /// Deprecated alias to `find_root_cause`.
159
+ #[ deprecated( since = "0.1.2" , note = "please use the 'find_root_cause()' method instead" ) ]
160
+ pub fn root_cause ( & self ) -> & Fail {
161
+ :: find_root_cause ( self . as_fail ( ) )
162
+ }
163
+
164
+ /// Deprecated alias to `iter_causes`.
165
+ #[ deprecated( since = "0.1.2" , note = "please use the 'iter_causes()' method instead" ) ]
153
166
pub fn causes ( & self ) -> Causes {
154
167
Causes { fail : Some ( self . as_fail ( ) ) }
155
168
}
0 commit comments