Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: display untrusted file on error #2423

Merged
merged 1 commit into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/config/config_file/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ pub fn trust_check(path: &Path) -> eyre::Result<()> {
return Ok(());
}
}
Err(UntrustedConfig())?
Err(UntrustedConfig(path.into()))?
}

static IS_TRUSTED: Lazy<Mutex<HashSet<PathBuf>>> = Lazy::new(|| Mutex::new(HashSet::new()));
Expand Down
14 changes: 10 additions & 4 deletions src/errors.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
use eyre::Report;
use std::path::PathBuf;
use std::process::ExitStatus;

use crate::toolset::{ToolRequest, ToolSource};
use eyre::Report;
use thiserror::Error;

use crate::file::display_path;
use crate::toolset::{ToolRequest, ToolSource};

#[derive(Debug, Error)]
pub enum Error {
#[error("Failed to resolve {tr} from {ts}: {source:#}")]
Expand All @@ -18,8 +21,11 @@ pub enum Error {
VersionNotInstalled(String, String),
#[error("{} exited with non-zero status: {}", .0, render_exit_status(.1))]
ScriptFailed(String, Option<ExitStatus>),
#[error("Config file is not trusted.\nTrust it with `mise trust`.")]
UntrustedConfig(),
#[error(
"Config file {} is not trusted.\nTrust it with `mise trust`.",
display_path(.0)
)]
UntrustedConfig(PathBuf),
}

fn render_exit_status(exit_status: &Option<ExitStatus>) -> String {
Expand Down
Loading