mirror of
https://github.com/haraldh/chainerror.git
synced 2025-01-31 09:04:14 +01:00
add find_chain_or_cause()
This commit is contained in:
parent
e7d4afb86c
commit
694cb4f273
10
src/lib.rs
10
src/lib.rs
|
@ -290,6 +290,16 @@ impl<T: 'static + Display + Debug> ChainError<T> {
|
||||||
.next()
|
.next()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME: naming
|
||||||
|
fn find_chain_or_cause<U: Error + 'static>(&self) -> Option<&U> {
|
||||||
|
self.iter()
|
||||||
|
.filter_map(|e| {
|
||||||
|
e.downcast_ref::<ChainError<U>>().map(|e| e.kind())
|
||||||
|
.or_else(|| e.downcast_ref::<U>())
|
||||||
|
})
|
||||||
|
.next()
|
||||||
|
}
|
||||||
|
|
||||||
/** return a reference to T of `ChainError<T>`
|
/** return a reference to T of `ChainError<T>`
|
||||||
|
|
||||||
# Examples
|
# Examples
|
||||||
|
|
Loading…
Reference in a new issue