Remove unwrap
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
nyyu 2021-03-15 07:46:48 +01:00
parent 3f7de3abac
commit 1c0dbb7bba

View file

@ -45,12 +45,11 @@ const USER_AGENT_VALUE: &str =
"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:87.0) Gecko/20100101 Firefox/87.0";
const LOL_CHAMPS_DIR: &str = ".\\champs";
fn main() {
fn main() -> Result<(), Box<dyn std::error::Error>> {
SimpleLogger::new()
.with_level(LevelFilter::Info)
.with_module_level("ureq", LevelFilter::Error)
.init()
.unwrap();
.init()?;
info!("CGG Item Sets");
@ -58,7 +57,7 @@ fn main() {
Ok(x) => x,
Err(_e) => PathBuf::from(LOL_CHAMPS_DIR),
};
info!("LoL Champs Folder: {}", lol_champs_dir.to_str().unwrap());
info!("LoL Champs Folder: {}", lol_champs_dir.to_str().unwrap_or(LOL_CHAMPS_DIR));
let client = ureq::AgentBuilder::new()
.timeout(Duration::from_secs(10))
@ -67,10 +66,8 @@ fn main() {
let realm: Realm = client
.get("https://ddragon.leagueoflegends.com/realms/euw.json")
.set(USER_AGENT_KEY, USER_AGENT_VALUE)
.call()
.unwrap()
.into_json()
.unwrap();
.call()?
.into_json()?;
info!("LoL version: {}", realm.v);
let champion: Champion = client
@ -79,10 +76,8 @@ fn main() {
realm.v
))
.set(USER_AGENT_KEY, USER_AGENT_VALUE)
.call()
.unwrap()
.into_json()
.unwrap();
.call()?
.into_json()?;
info!("LoL numbers of champs: {}", champion.data.len());
let data_sources: [Box<dyn DataSource>; 3] = [
@ -129,6 +124,7 @@ fn main() {
}
}
}
Ok(())
}
fn get_champ_from_key(champs: &Champion, key: &str) -> String {