Skip to content
This repository was archived by the owner on Aug 16, 2021. It is now read-only.

Commit 021ebed

Browse files
committed
Also introduce renames for error
1 parent bfd5e53 commit 021ebed

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

src/error/mod.rs

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,18 @@ impl Error {
125125
pub fn downcast<T: Fail>(self) -> Result<T, Error> {
126126
self.imp.downcast().map_err(|imp| Error { imp })
127127
}
128+
128129
/// Returns the "root cause" of this error - the last value in the
129130
/// 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()
132140
}
133141

134142
/// Attempts to downcast this `Error` to a particular `Fail` type by
@@ -147,9 +155,14 @@ impl Error {
147155
self.imp.failure_mut().downcast_mut()
148156
}
149157

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")]
153166
pub fn causes(&self) -> Causes {
154167
Causes { fail: Some(self.as_fail()) }
155168
}

0 commit comments

Comments
 (0)