Skip to main content

ix/
error.rs

1/// All ix error types.
2#[derive(Debug, thiserror::Error)]
3pub enum Error {
4    #[error("I/O: {0}")]
5    Io(#[from] std::io::Error),
6
7    #[error("index too small (< 256 bytes)")]
8    IndexTooSmall,
9
10    #[error("bad magic (expected IX01)")]
11    BadMagic,
12
13    #[error("unsupported version {major}.{minor}")]
14    UnsupportedVersion { major: u16, minor: u16 },
15
16    #[error("header CRC mismatch (expected {expected:#010x}, got {actual:#010x})")]
17    HeaderCorrupted { expected: u32, actual: u32 },
18
19    #[error("posting list corrupted (CRC mismatch)")]
20    PostingCorrupted,
21
22    #[error("section offset out of bounds: {section} at {offset}+{size} > {file_len}")]
23    SectionOutOfBounds {
24        section: &'static str,
25        offset: u64,
26        size: u64,
27        file_len: u64,
28    },
29
30    #[error("truncated varint at position {0}")]
31    TruncatedVarint(usize),
32
33    #[error("varint overflow (> 10 bytes)")]
34    OverflowVarint,
35
36    #[error("posting list out of bounds")]
37    PostingOutOfBounds,
38
39    #[error("file_id {0} out of bounds")]
40    FileIdOutOfBounds(u32),
41
42    #[error("string pool offset out of bounds")]
43    StringPoolOutOfBounds,
44
45    #[error("invalid UTF-8 in path")]
46    InvalidPath,
47
48    #[error("regex: {0}")]
49    Regex(#[from] regex::Error),
50
51    #[cfg(feature = "notify")]
52    #[error("Watcher error: {0}")]
53    Watcher(#[from] notify::Error),
54
55    #[cfg(feature = "archive")]
56    #[error("Zip error: {0}")]
57    Zip(#[from] zip::result::ZipError),
58
59    #[error("config: {0}")]
60    Config(String),
61}
62
63pub type Result<T> = std::result::Result<T, Error>;