fix(protocol): implement source/cause for Box<dyn Diagnostic>

This commit is contained in:
Kat Marchán 2021-09-16 19:08:12 -07:00
parent 9901030eb1
commit 3e8a27e263
No known key found for this signature in database
GPG Key ID: AEB529C08A3C7E9E
1 changed files with 9 additions and 1 deletions

View File

@ -52,7 +52,15 @@ pub trait Diagnostic: std::error::Error {
}
}
impl std::error::Error for Box<dyn Diagnostic> {}
impl std::error::Error for Box<dyn Diagnostic> {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
(**self).source()
}
fn cause(&self) -> Option<&dyn std::error::Error> {
self.source()
}
}
impl<T: Diagnostic + Send + Sync + 'static> From<T>
for Box<dyn Diagnostic + Send + Sync + 'static>