Impl helpers::await_task: Handle JoinError

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
Jiahao XU 2022-07-18 16:46:21 +10:00
parent 730f7d6c15
commit 5e7aab7373
No known key found for this signature in database
GPG key ID: 591C0B03040416D6

View file

@ -37,6 +37,11 @@ pub use tls_version::TLSVersion;
mod crate_name; mod crate_name;
pub use crate_name::CrateName; pub use crate_name::CrateName;
pub async fn await_task<T>(task: tokio::task::JoinHandle<T>) -> miette::Result<T> {
task.await
.map_err(|join_err| miette::miette!("Task failed to join: {}", join_err))
}
/// Load binstall metadata from the crate `Cargo.toml` at the provided path /// Load binstall metadata from the crate `Cargo.toml` at the provided path
pub fn load_manifest_path<P: AsRef<Path>>( pub fn load_manifest_path<P: AsRef<Path>>(
manifest_path: P, manifest_path: P,