diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main.rs | 16 | ||||
-rw-r--r-- | src/render.rs | 6 |
2 files changed, 14 insertions, 8 deletions
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 <kingdread@gmx.de>") - .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(()) diff --git a/src/render.rs b/src/render.rs index bb38399..90eff14 100644 --- a/src/render.rs +++ b/src/render.rs @@ -19,6 +19,9 @@ quick_error! { cause(err) from() } + EmptyBuild { + description("The build template contains nothing worth rendering") + } } } @@ -284,6 +287,9 @@ impl<'r> Renderer<'r> { build: &BuildTemplate, ) -> Result<RgbaImage, RenderError> { let images = self.construct_parts(build)?; + if images.is_empty() { + return Err(RenderError::EmptyBuild); + } self.merge_parts(&images) } |