From 399313cfbf706252e21828fe380ed3ddae4689fe Mon Sep 17 00:00:00 2001 From: matzxrr Date: Mon, 29 Jan 2024 23:45:44 -0700 Subject: [PATCH] feat: added better error for shell --- dotme-core/src/repo.rs | 2 -- dotme-core/src/shell.rs | 9 ++++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/dotme-core/src/repo.rs b/dotme-core/src/repo.rs index d20a2a5..190923f 100644 --- a/dotme-core/src/repo.rs +++ b/dotme-core/src/repo.rs @@ -9,8 +9,6 @@ use thiserror::Error; pub enum RepoError { #[error("repoistory config is invalid: {0}")] InvalidRepoConfig(String), - #[error("loading config.toml file: {0}")] - ConfigLoadError(#[from] crate::config::ConfigLoadError), #[error("git2: {0}")] Git2Error(#[from] Git2Error), #[error("unknown branch")] diff --git a/dotme-core/src/shell.rs b/dotme-core/src/shell.rs index 712bdae..099ec41 100644 --- a/dotme-core/src/shell.rs +++ b/dotme-core/src/shell.rs @@ -5,6 +5,8 @@ use thiserror::Error; pub enum ShellError { #[error("Can't find the users shell, might not be supported")] CannotFindShell, + #[error("Unknown shell '{0}'")] + UnknownShell(String), } type Result = std::result::Result; @@ -41,7 +43,7 @@ fn try_parse_shell(shell_path: &str) -> Result { }); } } - Err(ShellError::CannotFindShell) + Err(ShellError::UnknownShell(shell_path.to_owned())) } fn match_shell_to_config_file(shell: &str) -> Option { @@ -84,7 +86,8 @@ mod try_parse_shell_tests { } #[test] fn it_shouldnt_load_unknown_shell() { - let shell = try_parse_shell("/usr/bin/unknown"); - assert_eq!(shell, Err(ShellError::CannotFindShell)); + let shell_path = String::from("/usr/bin/unknown"); + let shell = try_parse_shell(&shell_path); + assert_eq!(shell, Err(ShellError::UnknownShell(shell_path))); } }