Skip to content

Commit

Permalink
fix: improve error on parsing lockfile (#1180)
Browse files Browse the repository at this point in the history
  • Loading branch information
ruben-arts authored Apr 15, 2024
1 parent 68d72c5 commit bf856ae
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/lock_file/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ mod satisfiability;
mod update;

use crate::Project;
use miette::IntoDiagnostic;
use miette::{IntoDiagnostic, WrapErr};
use rattler_conda_types::RepoDataRecord;
use rattler_lock::{LockFile, PypiPackageData, PypiPackageEnvironmentData};

Expand All @@ -35,9 +35,18 @@ pub async fn load_lock_file(project: &Project) -> miette::Result<LockFile> {
let lock_file_path = project.lock_file_path();
if lock_file_path.is_file() {
// Spawn a background task because loading the file might be IO bound.
tokio::task::spawn_blocking(move || LockFile::from_path(&lock_file_path).into_diagnostic())
.await
.unwrap_or_else(|e| Err(e).into_diagnostic())
tokio::task::spawn_blocking(move || {
LockFile::from_path(&lock_file_path)
.into_diagnostic()
.wrap_err_with(|| {
format!(
"Failed to load lock file from `{}`",
lock_file_path.display()
)
})
})
.await
.unwrap_or_else(|e| Err(e).into_diagnostic())
} else {
Ok(LockFile::default())
}
Expand Down

0 comments on commit bf856ae

Please sign in to comment.