Skip to content

Commit 9d0685c

Browse files
committed
added task name to 'UnexpectedHalt' error
1 parent 239ca62 commit 9d0685c

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

common/task/src/manager.rs

+13-3
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,18 @@ pub type SentStatus = Box<dyn Error + Send + Sync>;
2424
pub type StatusSender = futures::channel::mpsc::Sender<SentStatus>;
2525
pub type StatusReceiver = futures::channel::mpsc::Receiver<SentStatus>;
2626

27+
fn try_recover_name(name: &Option<String>) -> String {
28+
if let Some(name) = name {
29+
name.clone()
30+
} else {
31+
"unknown".to_string()
32+
}
33+
}
34+
2735
#[derive(thiserror::Error, Debug)]
2836
enum TaskError {
29-
#[error("Task halted unexpectedly")]
30-
UnexpectedHalt,
37+
#[error("Task ('{}') halted unexpectedly", try_recover_name(.shutdown_name))]
38+
UnexpectedHalt { shutdown_name: Option<String> },
3139
}
3240

3341
// TODO: possibly we should create a `Status` trait instead of reusing `Error`
@@ -455,7 +463,9 @@ impl Drop for TaskClient {
455463

456464
// If we can't send, well then there is not much to do
457465
self.drop_error
458-
.send(Box::new(TaskError::UnexpectedHalt))
466+
.send(Box::new(TaskError::UnexpectedHalt {
467+
shutdown_name: self.name.clone(),
468+
}))
459469
.ok();
460470
}
461471
}

0 commit comments

Comments
 (0)