From 4e9068acbf79244993fab4c33b29a207c219e4a8 Mon Sep 17 00:00:00 2001 From: Daniel Schadt Date: Fri, 13 Dec 2019 02:31:28 +0100 Subject: better output for image rendering errors So far, we silently ignored all errors, because we assumed that they would be the EmptyBuild anyway. This fixes this by not swallowing errors anymore, and instead displays them. --- src/main.rs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/main.rs b/src/main.rs index 55afb00..395e683 100644 --- a/src/main.rs +++ b/src/main.rs @@ -38,6 +38,7 @@ use clap::{App, Arg, ArgMatches}; use api::{Api, Profession, Skill}; use bt::{BuildTemplate, ExtraData, Legend, TraitChoice, Traitline}; +use render::RenderError; /// The name of this application. /// @@ -360,11 +361,18 @@ fn run() -> MainResult<()> { } let mut renderer = render::Renderer::new(&mut api, Default::default()); - 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); + match renderer.render_buildtemplate(&build) { + Ok(img) => { + let filename = matches.value_of("outfile").unwrap(); + img.save(filename)?; + if !matches.is_present("quiet") { + println!("Image saved in {}", filename); + } + }, + Err(RenderError::EmptyBuild) => (), + Err(err) => { + eprintln!("Image could not be rendered:"); + output::show_error(&err)?; } } -- cgit v1.2.3