diff options
author | jakob.stendahl <jakob.stendahl@infomedia.dk> | 2024-06-17 09:52:53 +0200 |
---|---|---|
committer | jakob.stendahl <jakob.stendahl@infomedia.dk> | 2024-06-17 09:52:53 +0200 |
commit | c82432863462bc893b5e1cc2e56fe1bfa9f4ba23 (patch) | |
tree | b3358d908e417ac9b8cc527f6fc22298f71eea13 | |
parent | 1a9b46180fa1e796f2ed0bf965141490900ec77e (diff) | |
download | textgraph-c82432863462bc893b5e1cc2e56fe1bfa9f4ba23.tar.gz textgraph-c82432863462bc893b5e1cc2e56fe1bfa9f4ba23.zip |
Don't panic on invalid lines when operating in filtering mode
-rw-r--r-- | src/main.rs | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/main.rs b/src/main.rs index e97b085..3a0a72c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -76,9 +76,15 @@ fn filter(opts: OptsBuilder) { i += 1.0; let line = line.expect("Could not read..."); - let y = f64::from_str(line.as_str()).expect("TG7 invalid number"); - y_values.push(y); - x_values.push(i); + let y = f64::from_str(line.as_str()); + if let Err(_) = y { + print!("Could not parse line as f64."); + continue; + } + if let Ok(y) = y { + y_values.push(y); + x_values.push(i); + } #[cfg(feature = "ansi")] print!("\x1B[2J\x1B[H"); |