diff options
author | Daniel Schadt <kingdread@gmx.de> | 2019-12-13 02:31:28 +0100 |
---|---|---|
committer | Daniel Schadt <kingdread@gmx.de> | 2019-12-13 02:31:28 +0100 |
commit | 4e9068acbf79244993fab4c33b29a207c219e4a8 (patch) | |
tree | 31c566f9b1af1a6eab700c9a36ed79ea5454cdf4 /src | |
parent | b66dc9a5863ecdb42e823db8d7ed0b253c0b75d0 (diff) | |
download | kondou-4e9068acbf79244993fab4c33b29a207c219e4a8.tar.gz kondou-4e9068acbf79244993fab4c33b29a207c219e4a8.tar.bz2 kondou-4e9068acbf79244993fab4c33b29a207c219e4a8.zip |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/main.rs | 18 |
1 files 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)?; } } |