add error message when running from a non-existent directory

This commit is contained in:
Tal Pressman 2023-08-15 08:08:00 +09:00 committed by tp-woven
parent 440a7a8f0e
commit 32fef364ef

View file

@ -2664,7 +2664,12 @@ impl CliRunner {
ui: &mut Ui,
mut layered_configs: LayeredConfigs,
) -> Result<(), CommandError> {
let cwd = env::current_dir().unwrap(); // TODO: maybe map_err to CommandError?
let cwd = env::current_dir().map_err(|_| {
user_error_with_hint(
"Could not determine current directory",
"Did you check-out a commit where the directory doesn't exist?",
)
})?;
layered_configs.read_user_config()?;
let config = layered_configs.merge();
ui.reset(&config)?;