Improve error handling
This commit is contained in:
parent
42b2f3ff7b
commit
6f71e41b71
37
src/main.rs
37
src/main.rs
@ -39,29 +39,30 @@ fn main() {
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
let guild_list = wynncraft::guild_list().unwrap();
|
||||
let conn = establish_connection();
|
||||
if let Ok(guild_list) = wynncraft::guild_list() {
|
||||
let conn = establish_connection();
|
||||
|
||||
guild_list.into_iter().for_each(|name| {
|
||||
thread::sleep_ms(2500);
|
||||
println!("Getting {:?}", name);
|
||||
if let Ok(Some(prefix)) = wynncraft::guild(&name).map(|x| x.map(|x| x.prefix)) {
|
||||
let guild = Guild { prefix: prefix.trim().to_owned(), name };
|
||||
if let Ok(_) = diesel::insert_into(guilds::table)
|
||||
.values(&guild)
|
||||
.on_conflict(guilds::prefix)
|
||||
.do_nothing()
|
||||
.execute(&conn) {
|
||||
let _ = reqwest::get("https://wynnapi.herokuapp.com/").unwrap();
|
||||
guild_list.into_iter().for_each(|name| {
|
||||
thread::sleep_ms(2500);
|
||||
println!("Getting {:?}", name);
|
||||
if let Ok(Some(prefix)) = wynncraft::guild(&name).map(|x| x.map(|x| x.prefix)) {
|
||||
let guild = Guild { prefix: prefix.trim().to_owned(), name };
|
||||
if let Ok(_) = diesel::insert_into(guilds::table)
|
||||
.values(&guild)
|
||||
.on_conflict(guilds::prefix)
|
||||
.do_nothing()
|
||||
.execute(&conn) {
|
||||
let _ = reqwest::get("https://wynnapi.herokuapp.com/").unwrap();
|
||||
} else {
|
||||
println!("Fail!");
|
||||
}
|
||||
} else {
|
||||
println!("Fail!");
|
||||
}
|
||||
} else {
|
||||
println!("Fail!");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
println!("Guilds updated!");
|
||||
println!("Guilds updated!");
|
||||
}
|
||||
|
||||
server_handle.join().unwrap();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user