Change error kind

This commit is contained in:
Jonathan Behrens committed 2022-09-05 12:45:22 -07:00
1 parent 945a02d1e1
commit fc0dafcde2
3 files changed
+4 -2

No files matched your search

+1 -1
View File
@@ -99,7 +99,7 @@ impl Image {
let height = tag_reader.require_tag(Tag::ImageLength)?.into_u32()?; let height = tag_reader.require_tag(Tag::ImageLength)?.into_u32()?;
if width == 0 || height == 0 { if width == 0 || height == 0 {
return Err(TiffError::FormatError( return Err(TiffError::FormatError(
TiffFormatError::InconsistentSizesEncountered, TiffFormatError::InvalidDimensions(width, height),
)); ));
} }
+1 -1
View File
@@ -352,7 +352,7 @@ impl<'a, W: 'a + Write + Seek, T: ColorType, K: TiffKind, D: Compression>
) -> TiffResult<Self> { ) -> TiffResult<Self> {
if width == 0 || height == 0 { if width == 0 || height == 0 {
return Err(TiffError::FormatError( return Err(TiffError::FormatError(
TiffFormatError::InconsistentSizesEncountered, TiffFormatError::InvalidDimensions(width, height),
)); ));
} }
+2
View File
@@ -56,6 +56,7 @@ pub enum TiffFormatError {
actual_samples: usize, actual_samples: usize,
required_samples: usize, required_samples: usize,
}, },
InvalidDimensions(u32, u32),
InvalidTag, InvalidTag,
InvalidTagValueType(Tag), InvalidTagValueType(Tag),
RequiredTagNotFound(Tag), RequiredTagNotFound(Tag),
@@ -100,6 +101,7 @@ impl fmt::Display for TiffFormatError {
actual_samples, required_samples actual_samples, required_samples
) )
} }
InvalidDimensions(width, height) => write!(fmt, "Invalid dimensions: {}x{}.", width, height),
InvalidTag => write!(fmt, "Image contains invalid tag."), InvalidTag => write!(fmt, "Image contains invalid tag."),
InvalidTagValueType(ref tag) => { InvalidTagValueType(ref tag) => {
write!(fmt, "Tag `{:?}` did not have the expected value type.", tag) write!(fmt, "Tag `{:?}` did not have the expected value type.", tag)