Skip to content

Commit

Permalink
Use Result
Browse files Browse the repository at this point in the history
  • Loading branch information
thecaralice committed Oct 3, 2020
1 parent 3d8c330 commit 7b00f97
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,25 +228,25 @@ impl Config {
.font(self.font.clone().unwrap_or_default())
.round_corner(!self.no_round_corner)
.window_controls(!self.no_window_controls)
.shadow_adder(self.get_shadow_adder())
.shadow_adder(self.get_shadow_adder()?)
.tab_width(self.tab_width)
.highlight_lines(self.highlight_lines.clone().unwrap_or_default());

Ok(formatter.build()?)
}

pub fn get_shadow_adder(&self) -> ShadowAdder {
ShadowAdder::new()
pub fn get_shadow_adder(&self) -> Result<ShadowAdder, Error> {
Ok(ShadowAdder::new()
.background(match &self.background_image {
Some(path) => Background::Image(image::open(path).unwrap().to_rgba()),
Some(path) => Background::Image(image::open(path)?.to_rgba()),
None => Background::Solid(self.background),
})
.shadow_color(self.shadow_color)
.blur_radius(self.shadow_blur_radius)
.pad_horiz(self.pad_horiz)
.pad_vert(self.pad_vert)
.offset_x(self.shadow_offset_x)
.offset_y(self.shadow_offset_y)
.offset_y(self.shadow_offset_y))
}

pub fn get_expanded_output(&self) -> Option<PathBuf> {
Expand Down

0 comments on commit 7b00f97

Please sign in to comment.