Skip to content

Commit

Permalink
Add better error reporting to is_executable
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperCuber committed Jul 13, 2024
1 parent 4ca49da commit 93c44e0
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/handlebars_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ fn is_executable_helper(
.into());
}

let status =
is_executable(&executable).map_err(|e| RenderErrorReason::NestedError(Box::new(e)))?;
let status = is_executable(&executable)
.map_err(|e| RenderErrorReason::Other(format!("failed to run is_executable: {e}")))?;
if status {
out.write("true")?;
}
Expand Down Expand Up @@ -230,7 +230,7 @@ fn command_output_helper(
}

#[cfg(windows)]
fn is_executable(name: &str) -> Result<bool, std::io::Error> {
fn is_executable(name: &str) -> Result<bool> {
let name = if name.ends_with(".exe") {
name.to_string()
} else {
Expand All @@ -244,6 +244,7 @@ fn is_executable(name: &str) -> Result<bool, std::io::Error> {
.stderr(Stdio::null())
.status()
.map(|s| s.success())
.context("run `where` command")
}

#[cfg(unix)]
Expand All @@ -255,6 +256,7 @@ fn is_executable(name: &str) -> Result<bool, std::io::Error> {
.stderr(Stdio::null())
.status()
.map(|s| s.success())
.context("run `which` command")
}

#[cfg(windows)]
Expand Down

0 comments on commit 93c44e0

Please sign in to comment.