Skip to content

Commit

Permalink
Merge #211
Browse files Browse the repository at this point in the history
211: improve the formatter load error r=zimbatm a=zimbatm



Co-authored-by: zimbatm <[email protected]>
  • Loading branch information
bors[bot] and zimbatm authored Jan 16, 2023
2 parents 127c222 + 0608646 commit b3930af
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ pub fn run_treefmt(
if allow_missing_formatter {
error!("Ignoring formatter #{} due to error: {}", name, err)
} else {
error!("Failed to load formatter #{} due to error: {}", name, err)
error!("Failed to load formatter #{}: {}", name, err)
}
}
};
Expand Down
6 changes: 4 additions & 2 deletions src/formatter.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Utilities for the formatters themselves.
use std::{fmt, path::Path, path::PathBuf, process::Command};

use anyhow::{anyhow, Result};
use anyhow::{anyhow, Context, Result};
use console::style;
use globset::{GlobBuilder, GlobSet, GlobSetBuilder};
use log::{debug, warn};
Expand Down Expand Up @@ -161,8 +161,10 @@ impl Formatter {
let name = FormatterName(name.to_string());
// Expand the work_dir to an absolute path, using the project root as a reference.
let work_dir = expand_path(&cfg.work_dir, tree_root);

// Resolve the path to the binary
let command = expand_exe(&cfg.command, tree_root)?;
let command = expand_exe(&cfg.command, tree_root)
.with_context(|| format!("could not find '{}' on PATH", &cfg.command))?;
debug!("Found {} at {}", cfg.command, command.display());
assert!(command.is_absolute());

Expand Down

0 comments on commit b3930af

Please sign in to comment.