From c86752e39dd015aa66c741be3e2312c6f0e69ef1 Mon Sep 17 00:00:00 2001 From: Daniel Schadt Date: Tue, 10 Dec 2019 14:48:54 +0100 Subject: avoid crashing with empty build templates This would occur if e.g. only the profession was given. --- src/main.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index d928c09..6194ef0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -226,8 +226,8 @@ fn validate_legend(input: String) -> Result<(), String> { fn run() -> MainResult<()> { let matches = App::new(APP_NAME) .version("0.1") - .author("Daniel ") - .about("Renders GW2 skills and traits.") + .author("Peter Parker IV") + .about("Renders Guild Wars 2 skills and traits.") .arg( Arg::with_name("profession") .help("Selects which profession to use.") @@ -304,12 +304,12 @@ fn run() -> MainResult<()> { } let mut renderer = render::Renderer::new(&mut api, Default::default()); - let img = renderer.render_buildtemplate(&build).unwrap(); - let filename = matches.value_of("outfile").unwrap(); - img.save(filename)?; - - if !matches.is_present("quiet") { - println!("Image saved in {}", filename); + if let Ok(img) = renderer.render_buildtemplate(&build) { + let filename = matches.value_of("outfile").unwrap(); + img.save(filename)?; + if !matches.is_present("quiet") { + println!("Image saved in {}", filename); + } } Ok(()) -- cgit v1.2.3