improve error message in case of unexpected panic while processing tasks

This commit is contained in:
Tamo 2025-01-29 11:51:06 +01:00
parent 42257eec53
commit 8439aeb7cf
No known key found for this signature in database
GPG key ID: 20CD8020AFA88D69
4 changed files with 30 additions and 8 deletions

View file

@ -172,7 +172,20 @@ impl IndexScheduler {
cloned_index_scheduler.process_batch(batch, processing_batch, progress)
})
.unwrap();
handle.join().unwrap_or(Err(Error::ProcessBatchPanicked))
match handle.join() {
Ok(ret) => ret,
Err(panic) => {
let msg = match panic.downcast_ref::<&'static str>() {
Some(s) => *s,
None => match panic.downcast_ref::<String>() {
Some(s) => &s[..],
None => "Box<dyn Any>",
},
};
Err(Error::ProcessBatchPanicked(msg.to_string()))
}
}
})
};