1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-21 15:04:11 -05:00

map lcms error

This commit is contained in:
Hajime-san 2024-10-24 17:55:34 +09:00
parent 50bee86fd5
commit 1429013dd1
3 changed files with 7 additions and 6 deletions

View file

@ -365,14 +365,12 @@ where
&output_icc_profile,
pixel_format,
output_icc_profile.header_rendering_intent(),
);
)
.map_err(CanvasError::Lcms)
.unwrap();
for (x, y, mut pixel) in image.pixels() {
let pixel = match transformer {
Ok(ref transformer) => pixel.transform_color_profile(transformer),
// This arm will reach when the ffi call fails.
Err(_) => pixel,
};
let pixel = pixel.transform_color_profile(&transformer);
out.put_pixel(x, y, pixel);
}

View file

@ -22,6 +22,8 @@ pub enum CanvasError {
#[error("Cannot decode image '{0}'")]
InvalidImage(String),
#[error(transparent)]
Lcms(#[from] lcms2::Error),
#[error(transparent)]
/// This error will be mapped to TypeError.
Image(#[from] image::ImageError),
}

View file

@ -603,6 +603,7 @@ fn get_canvas_error(e: &CanvasError) -> &'static str {
match e {
CanvasError::UnsupportedColorType(_) => "TypeError",
CanvasError::InvalidImage(_) => "DOMExceptionInvalidStateError",
CanvasError::Lcms(_) => "TypeError",
CanvasError::Image(_) => "TypeError",
}
}