Improve error message when $AUTIN_SESSION is not set. (#654)

Closes #653
This commit is contained in:
Jamie Quigley 2022-12-27 12:44:00 +00:00 committed by GitHub
parent a5616aea8f
commit b01d9f81b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -26,8 +26,10 @@ pub struct Context {
}
pub fn current_context() -> Context {
let session =
env::var("ATUIN_SESSION").expect("failed to find ATUIN_SESSION - check your shell setup");
let Ok(session) = env::var("ATUIN_SESSION") else {
eprintln!("ERROR: Failed to find $ATUIN_SESSION in the environment. Check that you have correctly set up your shell.");
std::process::exit(1);
};
let hostname = format!("{}:{}", whoami::hostname(), whoami::username());
let cwd = match env::current_dir() {
Ok(dir) => dir.display().to_string(),