clif-util: Use anyhow::Error for errors instead of String

Also does the same for `cranelift-filetests`.
This commit is contained in:
Nick Fitzgerald
2020-09-14 16:23:30 -07:00
parent 9fea412333
commit 31cbbd1d20
43 changed files with 415 additions and 443 deletions

View File

@@ -4,7 +4,6 @@
//! concurrently.
use crate::runone;
use crate::TestResult;
use cranelift_codegen::dbg::LOG_FILENAME_PREFIX;
use cranelift_codegen::timing;
use file_per_thread_logger;
@@ -22,8 +21,14 @@ struct Request(usize, PathBuf);
/// Reply from worker thread,
pub enum Reply {
Starting { jobid: usize, thread_num: usize },
Done { jobid: usize, result: TestResult },
Starting {
jobid: usize,
thread_num: usize,
},
Done {
jobid: usize,
result: anyhow::Result<Duration>,
},
Tick,
}
@@ -147,11 +152,11 @@ fn worker_thread(
// The test panicked, leaving us a `Box<Any>`.
// Panics are usually strings.
if let Some(msg) = e.downcast_ref::<String>() {
Err(format!("panicked in worker #{}: {}", thread_num, msg))
anyhow::bail!("panicked in worker #{}: {}", thread_num, msg)
} else if let Some(msg) = e.downcast_ref::<&'static str>() {
Err(format!("panicked in worker #{}: {}", thread_num, msg))
anyhow::bail!("panicked in worker #{}: {}", thread_num, msg)
} else {
Err(format!("panicked in worker #{}", thread_num))
anyhow::bail!("panicked in worker #{}", thread_num)
}
});