Check the case with invalid token

This commit is contained in:
2022-09-01 17:05:13 +02:00
parent 43a6d2c3a2
commit 62fa71ea6e
5 changed files with 84 additions and 15 deletions

View File

@ -1,6 +1,7 @@
extern crate core;
use std::error::Error;
use std::io::ErrorKind;
use std::sync::Arc;
use futures::future::join_all;
@ -39,11 +40,13 @@ async fn get_server_config(conf: &ClientConfig) -> Result<RemoteConfig, Box<dyn
.send()
.await?;
if req.status().as_u16() != 200 {
log::error!(
"Could not retrieve configuration! (got status {})",
req.status()
);
std::process::exit(2);
Err(std::io::Error::new(
ErrorKind::Other,
format!(
"Could not retrieve configuration! (got status {})",
req.status()
),
))?;
}
Ok(req.json::<RemoteConfig>().await?)
@ -70,8 +73,11 @@ pub async fn run_app(mut args: ClientConfig) -> std::io::Result<()> {
let remote_conf = match get_server_config(&args).await {
Ok(c) => c,
Err(e) => {
log::error!("Failed to fetch relay configuration from server! {}", e);
panic!();
Err(std::io::Error::new(
ErrorKind::Other,
format!("Failed to fetch relay configuration from server! {}", e),
))?;
unreachable!();
}
};