Handle JoinHandle panic in view
This commit is contained in:
parent
11402254e1
commit
aed8a28aac
|
@ -202,7 +202,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "hanimers"
|
||||
version = "0.1.2"
|
||||
version = "0.1.3"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"quick-xml",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "hanimers"
|
||||
version = "0.1.2"
|
||||
version = "0.1.3"
|
||||
authors = ["blank X <theblankx@protonmail.com>"]
|
||||
edition = "2018"
|
||||
|
||||
|
|
|
@ -20,14 +20,27 @@ pub async fn view(arg_m: &ArgMatches<'_>) {
|
|||
let handles = arg_m.values_of("id").unwrap().map(|id| {
|
||||
let cloned_client = client.clone();
|
||||
let id = id.to_string();
|
||||
tokio::spawn(async move {
|
||||
(utils::get_hentai(cloned_client, &id).await, id)
|
||||
})
|
||||
let cid = id.clone();
|
||||
(tokio::spawn(async move {
|
||||
utils::get_hentai(cloned_client, &cid).await
|
||||
}), id)
|
||||
}).collect::<Vec<_>>();
|
||||
let mut fail = false;
|
||||
let mut one_done = false;
|
||||
for handle in handles {
|
||||
let (hentai, id) = handle.await.unwrap();
|
||||
let (handle, id) = handle;
|
||||
let hentai = match handle.await {
|
||||
Ok(hentai) => hentai,
|
||||
Err(err) => {
|
||||
if one_done {
|
||||
eprintln!("");
|
||||
}
|
||||
eprintln!("ID: {}\nError: {}", id, err);
|
||||
fail = true;
|
||||
one_done = true;
|
||||
continue;
|
||||
}
|
||||
};
|
||||
match hentai {
|
||||
Ok(hentai) => {
|
||||
match hentai {
|
||||
|
|
|
@ -8,7 +8,7 @@ fn main() {
|
|||
let matches = App::new("hanimers")
|
||||
.about("hanime.tv downloader in rust")
|
||||
// let's hope i remember to bump the version xd
|
||||
.version("0.1.2")
|
||||
.version("0.1.3")
|
||||
.setting(AppSettings::SubcommandRequiredElseHelp)
|
||||
.subcommand(
|
||||
SubCommand::with_name("search")
|
||||
|
|
Loading…
Reference in New Issue