Skip to content

Commit 15b927f

Browse files
authored
Merge pull request #13 from ndfz/issue-12-fix-panic
fix(takeover): error handling that triggers a panic
2 parents 1e610e1 + 6de8396 commit 15b927f

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/commands/takeover/sub_takeover.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,13 @@ async fn load_platform_info(json_file: &str) -> Result<PlatformInfo, Box<dyn std
5858

5959
async fn process_takeover_urls(urls: &[String], platform_info: &PlatformInfo) {
6060
for url_str in urls {
61-
let url = url_str
62-
.parse::<reqwest::Url>()
63-
.unwrap();
61+
let url = match reqwest::Url::parse(url_str) {
62+
Ok(url) => url,
63+
Err(_) => {
64+
println!("{} -> [{}]", "Invalid URL".red().bold(), url_str);
65+
continue;
66+
}
67+
};
6468

6569
let body = reqwest::get(url.clone()) // Clone the Url
6670
.await

0 commit comments

Comments
 (0)