Skip to content

Commit

Permalink
show an error when wttr.in cannot be reached, fix #30
Browse files Browse the repository at this point in the history
  • Loading branch information
Yo'av Moshe committed Feb 25, 2024
1 parent 40a68d0 commit 8e6df27
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "wttrbar"
version = "0.7.1"
version = "0.8.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down
4 changes: 3 additions & 1 deletion main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use core::time;
use std::collections::HashMap;
use std::fs::{metadata, read_to_string, File};
use std::io::Write;
use std::process::exit;
use std::thread;
use std::time::{Duration, SystemTime};

Expand Down Expand Up @@ -159,7 +160,8 @@ fn main() {
thread::sleep(time::Duration::from_millis(500 * iterations));

if iterations == threshold {
panic!("No response from endpoint!");
println!("{{\"text\":\"⛓️‍💥\", \"tooltip\":\"cannot access wttr.in\"}}");
exit(0)
}
}
}
Expand Down

0 comments on commit 8e6df27

Please sign in to comment.