-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🔀 ✨ QoL Update: Refinements and Enhancements
- Loading branch information
Showing
10 changed files
with
169 additions
and
139 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,42 @@ | ||
use reqwest::blocking as request; | ||
use reqwest::blocking::get; | ||
|
||
use crate::logger::alert; | ||
use crate::system::exit; | ||
use crate::system::Envs; | ||
use crate::{logger, system}; | ||
|
||
pub fn check(env: &Envs) { | ||
pub fn check(env: &system::Envs) { | ||
// Check if the API can be reached. | ||
match request::get(&format!( | ||
match get(&format!( | ||
"{}/api/v3/health?apikey={}", | ||
&env.baseurl, &env.apikey | ||
env.baseurl, env.apikey | ||
)) { | ||
// Can be reached, continue. | ||
Ok(res) => { | ||
// Let's just assume that the APIKEY is | ||
// invalid if the code returned is not "200". | ||
if res.status() != 200 { | ||
alert( | ||
logger::alert( | ||
"FATAL", | ||
format!("The provided \"APIKEY\" is not valid."), | ||
format!( | ||
"Obtain the {} API key in Settings > General > API Key", | ||
&env.platform | ||
env.platform | ||
), | ||
None, | ||
); | ||
exit(1); | ||
system::exit(1); | ||
} | ||
} | ||
// Could not be reached. | ||
Err(error) => { | ||
alert( | ||
logger::alert( | ||
"FATAL", | ||
format!( | ||
"A connection to the {} API could not be established.", | ||
&env.platform | ||
env.platform | ||
), | ||
"Ensure that the API is accessible and try again.".to_string(), | ||
Some(error.to_string()), | ||
); | ||
exit(1); | ||
system::exit(1); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.