mirror of
https://github.com/dnlbauer/xdrfile.git
synced 2026-09-10 22:25:30 +00:00
Error::task() now checks sources
This commit is contained in:
@@ -43,8 +43,11 @@ impl Error {
|
|||||||
|
|
||||||
/// Get the task being attempted when the C API returned an error, if any
|
/// Get the task being attempted when the C API returned an error, if any
|
||||||
pub fn task(&self) -> Option<ErrorTask> {
|
pub fn task(&self) -> Option<ErrorTask> {
|
||||||
|
use std::error::Error as _;
|
||||||
if let Error::CApiError { task, .. } = self {
|
if let Error::CApiError { task, .. } = self {
|
||||||
Some(*task)
|
Some(*task)
|
||||||
|
} else if let Some(e) = self.source() {
|
||||||
|
e.downcast_ref::<Self>().and_then(Self::task)
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user