Skip to content

Commit

Permalink
fix(cli): Improve error on missing config
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed Aug 18, 2023
1 parent 03e6afb commit e003ac8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion crates/typos-cli/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,13 @@ impl Config {
}

pub fn from_file(path: &std::path::Path) -> Result<Self, anyhow::Error> {
let s = std::fs::read_to_string(path)?;
let s = std::fs::read_to_string(path).map_err(|err| {
let kind = err.kind();
std::io::Error::new(
kind,
format!("could not read config at `{}`", path.display()),
)
})?;
Self::from_toml(&s)
}

Expand Down
2 changes: 1 addition & 1 deletion crates/typos-cli/tests/cmd/missing-config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ status.code = 78
stdin = ""
# stdout doesn't have stable order
stderr = """
No such file or directory (os error 2)
could not read config at `foo.toml`
"""

0 comments on commit e003ac8

Please sign in to comment.