1use std::path::PathBuf;
2use thiserror::Error;
34/// 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)]
9Internal(#[from] Box<dyn core::error::Error + Send + Sync>),
1011/// An error occurred while disconnecting, wrapping a standard I/O error.
12#[error(transparent)]
13Disconnect(#[from] std::io::Error),
1415/// An error related to the file system occurred, wrapping a file system path error.
16#[error(transparent)]
17FileSystem(#[from] reth_fs_util::FsPathError),
1819/// A custom error message provided by the user.
20#[error("{0}")]
21Custom(String),
2223/// An error occurred during serialization/deserialization with Bincode.
24#[error(transparent)]
25Bincode(#[from] Box<bincode::ErrorKind>),
2627/// An error occurred with the Elias-Fano encoding/decoding process.
28#[error(transparent)]
29EliasFano(#[from] anyhow::Error),
3031/// Compression was enabled, but the compressor is not ready yet.
32#[error("compression was enabled, but it's not ready yet")]
33CompressorNotReady,
3435/// Decompression was enabled, but the decompressor is not ready yet.
36#[error("decompression was enabled, but it's not ready yet")]
37DecompressorNotReady,
3839/// The number of columns does not match the expected length.
40#[error("number of columns does not match: {0} != {1}")]
41ColumnLenMismatch(usize, usize),
4243/// An unexpected missing value was encountered at a specific row and column.
44#[error("unexpected missing value: row:col {0}:{1}")]
45UnexpectedMissingValue(u64, u64),
4647/// 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}")]
49OffsetSizeTooBig {
50/// The read offset size in number of bytes.
51offset_size: u8,
52 },
5354/// 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}")]
56OffsetSizeTooSmall {
57/// The read offset size in number of bytes.
58offset_size: u8,
59 },
6061/// An attempt was made to read an offset that is out of bounds.
62#[error("attempted to read an out of bounds offset: {index}")]
63OffsetOutOfBounds {
64/// The index of the offset that was being read.
65index: usize,
66 },
6768/// The output buffer is too small for the compression or decompression operation.
69#[error("compression or decompression requires a bigger destination output")]
70OutputTooSmall,
7172/// A dictionary is not loaded when it is required for operations.
73#[error("dictionary is not loaded.")]
74DictionaryNotLoaded,
7576/// 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.")]
78CompressorNotAllowed,
7980/// The number of offsets is smaller than the requested prune size.
81#[error("number of offsets ({0}) is smaller than prune request ({1}).")]
82InvalidPruning(u64, u64),
8384/// The jar has been frozen and cannot be modified.
85#[error("jar has been frozen and cannot be modified.")]
86FrozenJar,
8788/// The file is in an inconsistent state.
89#[error("File is in an inconsistent state.")]
90InconsistentState,
9192/// A specified file is missing.
93#[error("Missing file: {}", .0.display())]
94MissingFile(PathBuf),
95}