diff options
| author | Aram Drevekenin <aram@poor.dev> | 2026-07-06 08:55:09 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-07-06 08:55:09 +0200 |
| commit | 7b823f972ada878456d0dc91fc6b3472972f045a (patch) | |
| tree | 5390af17d03b7824ef1390c11bac0e3486eed1ee /src | |
| parent | Stacked lists (#5331) (diff) | |
| download | sl0ppij-7b823f972ada878456d0dc91fc6b3472972f045a.tar.gz sl0ppij-7b823f972ada878456d0dc91fc6b3472972f045a.tar.xz sl0ppij-7b823f972ada878456d0dc91fc6b3472972f045a.zip | |
fix: more verbose startup errors (#5334)
* fix: more verbose startup errors
* add pr
Diffstat (limited to 'src')
| -rw-r--r-- | src/commands.rs | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/src/commands.rs b/src/commands.rs index 4d3b83d8..bc561a75 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -18,7 +18,7 @@ use zellij_utils::sessions::{ generate_unique_session_name, get_active_session, get_resurrectable_sessions, get_sessions, get_sessions_sorted_by_mtime, kill_session as kill_session_impl, match_session_name, print_sessions, print_sessions_with_index, resurrection_layout, session_exists, - validate_session_name, ActiveSession, SessionNameMatch, + session_listing_error_message, validate_session_name, ActiveSession, SessionNameMatch, }; use zellij_utils::consts::session_layout_cache_file_name; @@ -629,18 +629,19 @@ fn attach_with_session_name( create: bool, ) -> ClientInfo { match &session_name { - Some(session) if create => { - if session_exists(session).unwrap() { - ClientInfo::Attach(session_name.unwrap(), config_options) - } else { - ClientInfo::New(session_name.unwrap(), None, None) - } + Some(session) if create => match session_exists(session) { + Ok(true) => ClientInfo::Attach(session_name.unwrap(), config_options), + Ok(false) => ClientInfo::New(session_name.unwrap(), None, None), + Err(kind) => { + eprintln!("{}", session_listing_error_message(kind)); + process::exit(1); + }, }, - Some(prefix) => match match_session_name(prefix).unwrap() { - SessionNameMatch::UniquePrefix(s) | SessionNameMatch::Exact(s) => { + Some(prefix) => match match_session_name(prefix) { + Ok(SessionNameMatch::UniquePrefix(s)) | Ok(SessionNameMatch::Exact(s)) => { ClientInfo::Attach(s, config_options) }, - SessionNameMatch::AmbiguousPrefix(sessions) => { + Ok(SessionNameMatch::AmbiguousPrefix(sessions)) => { println!( "Ambiguous selection: multiple sessions names start with '{}':", prefix @@ -656,10 +657,14 @@ fn attach_with_session_name( ); process::exit(1); }, - SessionNameMatch::None => { + Ok(SessionNameMatch::None) => { eprintln!("No session with the name '{}' found!", prefix); process::exit(1); }, + Err(kind) => { + eprintln!("{}", session_listing_error_message(kind)); + process::exit(1); + }, }, None => match get_active_session() { ActiveSession::None if create => create_new_client(), |
