diff --git a/common/task/src/manager.rs b/common/task/src/manager.rs index a99e036231..a2a7cdd087 100644 --- a/common/task/src/manager.rs +++ b/common/task/src/manager.rs @@ -24,10 +24,18 @@ pub type SentStatus = Box; pub type StatusSender = futures::channel::mpsc::Sender; pub type StatusReceiver = futures::channel::mpsc::Receiver; +fn try_recover_name(name: &Option) -> String { + if let Some(name) = name { + name.clone() + } else { + "unknown".to_string() + } +} + #[derive(thiserror::Error, Debug)] enum TaskError { - #[error("Task halted unexpectedly")] - UnexpectedHalt, + #[error("Task '{}' halted unexpectedly", try_recover_name(.shutdown_name))] + UnexpectedHalt { shutdown_name: Option }, } // TODO: possibly we should create a `Status` trait instead of reusing `Error` @@ -455,7 +463,9 @@ impl Drop for TaskClient { // If we can't send, well then there is not much to do self.drop_error - .send(Box::new(TaskError::UnexpectedHalt)) + .send(Box::new(TaskError::UnexpectedHalt { + shutdown_name: self.name.clone(), + })) .ok(); } }