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("not all blocks were written: wrote {written} of {total}")]
27 IncompleteImage { written: usize, total: usize },
28
29 #[error("writer has already been finalized")]
30 AlreadyFinalized,
31
32 #[error("classic TIFF offset {offset} exceeds 4 GiB limit; use TiffVariant::BigTiff")]
33 ClassicOffsetOverflow { offset: u64 },
34
35 #[error("classic TIFF byte count {byte_count} exceeds 4 GiB limit; use TiffVariant::BigTiff")]
36 ClassicByteCountOverflow { byte_count: u64 },
37
38 #[error("{0}")]
39 Other(String),
40}