Skip to content

Commit

Permalink
More error cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
esamattis committed Sep 21, 2024
1 parent fd924fe commit 2431044
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
9 changes: 4 additions & 5 deletions src/composer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,11 @@ impl ComposerRunner {
return Ok(script_names);
}

bail!("Failed to read composer.json: {}", e.to_string());
bail!(e);
}
};

let json: Value = serde_json::from_str(&content).with_context(|| {
return format!("Failed to parse composer.json");
})?;
let json: Value = serde_json::from_str(&content).context("Failed to parse JSON")?;

let Some(scripts) = json["scripts"].as_object() else {
return Ok(script_names);
Expand All @@ -56,7 +54,8 @@ impl Runner for ComposerRunner {
}

fn load(&mut self) -> Result<()> {
let scripts = ComposerRunner::read_composer_json()?;
let scripts =
ComposerRunner::read_composer_json().context("Failed to read composer.json")?;
self.tasks = scripts;
return Ok(());
}
Expand Down
6 changes: 3 additions & 3 deletions src/npm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ impl NpmRunner {
return Ok(script_names);
}

bail!("Failed to read package.json: {}", e.to_string());
bail!(e);
}
};

let json: Value = serde_json::from_str(&content).context("failed to parse package.json")?;
let json: Value = serde_json::from_str(&content).context("Failed to parse JSON")?;

let Some(scripts) = json["scripts"].as_object() else {
return Ok(script_names);
Expand All @@ -55,7 +55,7 @@ impl Runner for NpmRunner {
}

fn load(&mut self) -> Result<()> {
let scripts = NpmRunner::read_package_json()?;
let scripts = NpmRunner::read_package_json().context("Failed to read package.json")?;
self.tasks = scripts;
return Ok(());
}
Expand Down

0 comments on commit 2431044

Please sign in to comment.