Skip to content

Commit

Permalink
Basic error handling if offset nan
Browse files Browse the repository at this point in the history
  • Loading branch information
jeselnik committed Jan 20, 2020
1 parent 4d8b228 commit 525319c
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ fn main() {
.expect("Failed to parse file path!");
/* Get argument value and unwrap to type str, then parse the string and unwrap str for
* conversion to f32*/
let timezone_offset: f32 = arguments.value_of("offset").unwrap().parse().unwrap();
let timezone_offset: f32 = arguments
.value_of("offset")
.unwrap()
.parse()
.expect("Offset not a number!");

let mut scrobbler = rustfm_scrobble::Scrobbler::new(api_keys::API_KEY, api_keys::API_SECRET);

Expand Down Expand Up @@ -55,13 +59,12 @@ fn main() {
println!("Delete file \"{}\"?", file_path);

let mut user_choice = string::String::new();
io::stdin().read_line(&mut user_choice)
io::stdin()
.read_line(&mut user_choice)
.expect("Failed to read from stdout!");

if user_choice.to_lowercase().starts_with("y") {
fs::remove_file(file_path)
.expect("I/O Error!");
fs::remove_file(file_path).expect("I/O Error!");
println!("\"{}\" deleted!", file_path);
}

}

0 comments on commit 525319c

Please sign in to comment.