diff --git a/crates/snm_core/src/model/snm_error.rs b/crates/snm_core/src/model/snm_error.rs index 27a32e11..8fb7fd06 100644 --- a/crates/snm_core/src/model/snm_error.rs +++ b/crates/snm_core/src/model/snm_error.rs @@ -149,11 +149,11 @@ impl From for SnmError { // } // } -impl From for SnmError { - fn from(_error: reqwest::Error) -> Self { - SnmError::UnknownError - } -} +// impl From for SnmError { +// fn from(_error: reqwest::Error) -> Self { +// SnmError::UnknownError +// } +// } // impl From for SnmError { // fn from(_error: dialoguer::Error) -> Self { diff --git a/crates/snm_core/src/utils/download.rs b/crates/snm_core/src/utils/download.rs index 4676aa6b..7720356e 100644 --- a/crates/snm_core/src/utils/download.rs +++ b/crates/snm_core/src/utils/download.rs @@ -103,7 +103,11 @@ impl DownloadBuilder { let client = reqwest::Client::new(); - let response = client.get(download_url).send().await?; + let response = client + .get(download_url) + .send() + .await + .expect(format!("download error {}", &download_url).as_str()); let response_status = response.status(); @@ -141,7 +145,7 @@ impl DownloadBuilder { progress_bar.set_message(download_url.to_string()); while let Some(chunk) = stream.next().await { - let chunk = chunk?; + let chunk = chunk.expect("download stream chunk error"); file.write_all(&chunk).await?; diff --git a/crates/snm_node/src/snm_node.rs b/crates/snm_node/src/snm_node.rs index 9d8f4bc1..893b4c7e 100644 --- a/crates/snm_node/src/snm_node.rs +++ b/crates/snm_node/src/snm_node.rs @@ -5,6 +5,7 @@ use crate::node_model::Lts; use crate::node_model::NodeModel; use crate::node_schedule::NodeSchedule; use async_trait::async_trait; +use chrono::format; use chrono::NaiveDate; use chrono::Utc; use colored::*; @@ -43,9 +44,11 @@ impl SnmNode { let host = self.snm_config.get_nodejs_host(); let node_list_url = format!("{}/dist/index.json", host); let node_vec: Vec = reqwest::get(&node_list_url) - .await? + .await + .expect(format!("get {} error", &node_list_url).as_str()) .json::>() - .await?; + .await + .expect(format!("{} response transform to json failed", &node_list_url).as_str()); Ok(node_vec) } @@ -55,9 +58,11 @@ impl SnmNode { let node_schedule_url = format!("{}/nodejs/Release/main/schedule.json", host); let node_schedule_vec: Vec = reqwest::get(&node_schedule_url) - .await? + .await + .expect(format!("get {} error", &node_schedule_url).as_str()) .json::>() - .await? + .await + .expect(format!("{} response transform to json failed", &node_schedule_url).as_str()) .into_iter() .map(|(v, mut schedule)| { schedule.version = Some(v[1..].to_string()); @@ -75,7 +80,12 @@ impl SnmNode { let host = self.snm_config.get_nodejs_host(); let url = format!("{}/dist/v{}/SHASUMS256.txt", host, node_version); - let sha256_str = reqwest::get(&url).await?.text().await?; + let sha256_str = reqwest::get(&url) + .await + .expect(format!("get {} error", &url).as_str()) + .text() + .await + .expect("transform text error"); let sha256_map: std::collections::HashMap = sha256_str .lines() diff --git a/crates/snm_npm/src/snm_npm.rs b/crates/snm_npm/src/snm_npm.rs index 3fbe5472..50f7a84f 100644 --- a/crates/snm_npm/src/snm_npm.rs +++ b/crates/snm_npm/src/snm_npm.rs @@ -105,7 +105,12 @@ impl ManageTrait for SnmNpm { let npm_registry = self.snm_config.get_npm_registry_host(); let download_url = format!("{}/{}/{}", npm_registry, &self.prefix, &v); - let value: Value = reqwest::get(&download_url).await?.json().await?; + let value: Value = reqwest::get(&download_url) + .await + .expect(format!("download error {}", &download_url).as_str()) + .json() + .await + .expect(format!("json error {}", &download_url).as_str()); let x = value .get("dist")