fix(tonic): Status code to set correct source on unkown error (#799)

This commit is contained in:
Lucio Franco
2021-10-19 11:52:59 -04:00
committed by GitHub
parent c1fe31c1a3
commit 4054d61e14
2 changed files with 79 additions and 2 deletions
+5 -2
View File
@@ -305,8 +305,11 @@ impl Status {
#[cfg_attr(not(feature = "transport"), allow(dead_code))]
pub(crate) fn from_error(err: Box<dyn Error + Send + Sync + 'static>) -> Status {
Status::try_from_error(err)
.unwrap_or_else(|err| Status::new(Code::Unknown, err.to_string()))
Status::try_from_error(err).unwrap_or_else(|err| {
let mut status = Status::new(Code::Unknown, err.to_string());
status.source = Some(err);
status
})
}
pub(crate) fn try_from_error(