Skip to content

Commit 37f6d3b

Browse files
authored
Preserve existing Error values when converting from anyhow::Error. (#118)
Falls back to internal error conversion otherwise. Signed-off-by: Ben Brandt <benjamin.j.brandt@gmail.com>
1 parent e64f4af commit 37f6d3b

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

rust/error.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,10 @@ impl Display for Error {
206206

207207
impl From<anyhow::Error> for Error {
208208
fn from(error: anyhow::Error) -> Self {
209-
Error::into_internal_error(&*error)
209+
match error.downcast::<Self>() {
210+
Ok(error) => error,
211+
Err(error) => Error::into_internal_error(&*error),
212+
}
210213
}
211214
}
212215

0 commit comments

Comments
 (0)