1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-01-21 04:52:26 -05:00

use ImageError instead of string

- https://github.com/denoland/deno/pull/25517#discussion_r1861402027
This commit is contained in:
Hajime-san 2024-11-28 11:41:25 +09:00
parent 40cee983a3
commit 7039401fbe

View file

@ -19,7 +19,7 @@ pub enum CanvasError {
UnsupportedColorType(ColorType),
/// This error will be mapped to DOMExceptionInvalidStateError.
#[error("Cannot decode image '{0}'")]
InvalidImage(String),
InvalidImage(image::ImageError),
/// This error will be mapped to DOMExceptionInvalidStateError.
#[error("The chunk data is not big enough with the specified width: {0} and height: {1}.")]
NotBigEnoughChunk(u32, u32),
@ -37,7 +37,7 @@ pub enum CanvasError {
impl CanvasError {
/// Convert an [`image::ImageError`] to an [`CanvasError::InvalidImage`].
fn image_error_to_invalid_image(error: image::ImageError) -> Self {
Self::InvalidImage(error.to_string())
CanvasError::InvalidImage(error)
}
}