Skip to content

Commit

Permalink
Removes the panic, throws a warning & returns an empty list, which sh…
Browse files Browse the repository at this point in the history
…ould be expected behavior (#73)

* refactor(errors): better message when languaage directory doesn't exist

* refactor(languages_errors): better approach to the languages directory
  • Loading branch information
joao-vitor-sr committed Sep 29, 2023
1 parent d1fb17c commit 237223e
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,13 @@ fn main() -> crossterm::Result<()> {
}

if opt.list_languages {
opt.languages()
.expect("Couldn't get installed languages under config directory. Make sure the config directory exists.")
match opt.languages() {
Ok(languages) => languages,
Err(_) => {
println!("Warning: Couldn't get installed languages under config directory. Make sure the config directory exists.");
vec![]
}
}
.iter()
.for_each(|name| println!("{}", name.to_str().expect("Ill-formatted language name.")));
return Ok(());
Expand Down

0 comments on commit 237223e

Please sign in to comment.