From 7ee04620f6dfce69ed888d362851d093a64c28ec Mon Sep 17 00:00:00 2001 From: Josh Mitchell Date: Tue, 10 Nov 2020 20:11:15 +1100 Subject: [PATCH] Error::task() now checks sources --- src/errors.rs | 3 +++ 1 file changed, 3 insertions(+) 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 }