diff --git a/src/errors.rs b/src/errors.rs index c03a07a..cf5d1cd 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -43,8 +43,11 @@ impl Error { /// Get the task being attempted when the C API returned an error, if any pub fn task(&self) -> Option { + use std::error::Error as _; if let Error::CApiError { task, .. } = self { Some(*task) + } else if let Some(e) = self.source() { + e.downcast_ref::().and_then(Self::task) } else { None }