Skip to main content

tiff_writer/
error.rs

1use thiserror::Error;
2
3pub type Result<T> = std::result::Result<T, Error>;
4
5#[derive(Debug, Error)]
6pub enum Error {
7    #[error("I/O error: {0}")]
8    Io(#[from] std::io::Error),
9
10    #[error("invalid configuration: {0}")]
11    InvalidConfig(String),
12
13    #[error("compression failed for block {index}: {reason}")]
14    CompressionFailed { index: usize, reason: String },
15
16    #[error("block {index} has wrong sample count: expected {expected}, got {actual}")]
17    BlockSizeMismatch {
18        index: usize,
19        expected: usize,
20        actual: usize,
21    },
22
23    #[error("block index {index} is out of range (expected < {total})")]
24    BlockIndexOutOfRange { index: usize, total: usize },
25
26    #[error("block {index} has already been written")]
27    BlockAlreadyWritten { index: usize },
28
29    #[error("image handle does not belong to this writer")]
30    InvalidImageHandle,
31
32    #[error("not all blocks were written: wrote {written} of {total}")]
33    IncompleteImage { written: usize, total: usize },
34
35    #[error("classic TIFF offset {offset} exceeds 4 GiB limit; use TiffVariant::BigTiff")]
36    ClassicOffsetOverflow { offset: u64 },
37
38    #[error("classic TIFF byte count {byte_count} exceeds 4 GiB limit; use TiffVariant::BigTiff")]
39    ClassicByteCountOverflow { byte_count: u64 },
40
41    #[error("{0}")]
42    Other(String),
43}