From ac2db79f21265b54334a9eda93647c6346b89713 Mon Sep 17 00:00:00 2001 From: Neshura Date: Sun, 26 Feb 2023 01:14:33 +0100 Subject: [PATCH] Implemented Soft exit during IP-Fetching --- src/main.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index bb16a87..621e1ce 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,6 @@ use serde_derive::{Deserialize, Serialize}; use reqwest::blocking::get; -use std::fs; +use std::{fs, process::exit}; mod cloudflare; #[derive(Serialize, Deserialize)] @@ -68,7 +68,10 @@ impl Ips { match response { Ok(data) => self.ipv4 = data.text().expect("0.0.0.0").trim_end().to_owned(), - Err(e) => panic!("{:#?}", e) + Err(e) => { + println!("Could not fetch IP4, quitting"); + exit(75); + } } let response = get(ipv6uri); @@ -82,7 +85,10 @@ impl Ips { }; self.ipv6base = stripped; }, - Err(e) => panic!("{:#?}", e) + Err(e) => { + println!("Could not fetch IP6, quitting"); + exit(75); + } } } }