reth_nippy_jar/
error.rs

1use std::path::PathBuf;
2use thiserror::Error;
3
4/// Errors associated with [`crate::NippyJar`].
5#[derive(Error, Debug)]
6pub enum NippyJarError {
7    /// An internal error occurred, wrapping any type of error.
8    #[error(transparent)]
9    Internal(#[from] Box<dyn core::error::Error + Send + Sync>),
10
11    /// An error occurred while disconnecting, wrapping a standard I/O error.
12    #[error(transparent)]
13    Disconnect(#[from] std::io::Error),
14
15    /// An error related to the file system occurred, wrapping a file system path error.
16    #[error(transparent)]
17    FileSystem(#[from] reth_fs_util::FsPathError),
18
19    /// A custom error message provided by the user.
20    #[error("{0}")]
21    Custom(String),
22
23    /// An error occurred during serialization/deserialization with Bincode.
24    #[error(transparent)]
25    Bincode(#[from] Box<bincode::ErrorKind>),
26
27    /// An error occurred with the Elias-Fano encoding/decoding process.
28    #[error(transparent)]
29    EliasFano(#[from] anyhow::Error),
30
31    /// Compression was enabled, but the compressor is not ready yet.
32    #[error("compression was enabled, but it's not ready yet")]
33    CompressorNotReady,
34
35    /// Decompression was enabled, but the decompressor is not ready yet.
36    #[error("decompression was enabled, but it's not ready yet")]
37    DecompressorNotReady,
38
39    /// The number of columns does not match the expected length.
40    #[error("number of columns does not match: {0} != {1}")]
41    ColumnLenMismatch(usize, usize),
42
43    /// An unexpected missing value was encountered at a specific row and column.
44    #[error("unexpected missing value: row:col {0}:{1}")]
45    UnexpectedMissingValue(u64, u64),
46
47    /// The size of an offset exceeds the maximum allowed size of 8 bytes.
48    #[error("the size of an offset must be at most 8 bytes, got {offset_size}")]
49    OffsetSizeTooBig {
50        /// The read offset size in number of bytes.
51        offset_size: u8,
52    },
53
54    /// The size of an offset is less than the minimum allowed size of 1 byte.
55    #[error("the size of an offset must be at least 1 byte, got {offset_size}")]
56    OffsetSizeTooSmall {
57        /// The read offset size in number of bytes.
58        offset_size: u8,
59    },
60
61    /// An attempt was made to read an offset that is out of bounds.
62    #[error("attempted to read an out of bounds offset: {index}")]
63    OffsetOutOfBounds {
64        /// The index of the offset that was being read.
65        index: usize,
66    },
67
68    /// The output buffer is too small for the compression or decompression operation.
69    #[error("compression or decompression requires a bigger destination output")]
70    OutputTooSmall,
71
72    /// A dictionary is not loaded when it is required for operations.
73    #[error("dictionary is not loaded.")]
74    DictionaryNotLoaded,
75
76    /// It's not possible to generate a compressor after loading a dictionary.
77    #[error("it's not possible to generate a compressor after loading a dictionary.")]
78    CompressorNotAllowed,
79
80    /// The number of offsets is smaller than the requested prune size.
81    #[error("number of offsets ({0}) is smaller than prune request ({1}).")]
82    InvalidPruning(u64, u64),
83
84    /// The jar has been frozen and cannot be modified.
85    #[error("jar has been frozen and cannot be modified.")]
86    FrozenJar,
87
88    /// The file is in an inconsistent state.
89    #[error("File is in an inconsistent state.")]
90    InconsistentState,
91
92    /// A specified file is missing.
93    #[error("Missing file: {}", .0.display())]
94    MissingFile(PathBuf),
95}