Skip to main content

journal_core/
error.rs

1use std::io;
2use thiserror::Error;
3
4#[derive(Error, Debug)]
5pub enum JournalError {
6    #[error("writer poisoned after uncertain mutation")]
7    WriterPoisoned,
8
9    #[error("invalid magic number")]
10    InvalidMagicNumber,
11
12    #[error("invalid journal file state")]
13    InvalidJournalFileState,
14
15    #[error("unsupported journal file")]
16    UnsupportedJournalFile,
17
18    #[error("invalid object type")]
19    InvalidObjectType,
20
21    #[error("invalid object size: {0}")]
22    InvalidObjectSize(u64),
23
24    #[error("object exceeds file bounds")]
25    ObjectExceedsFileBounds,
26
27    #[error("invalid object location")]
28    InvalidObjectLocation,
29
30    #[error("invalid zerocopy size")]
31    InvalidZeroCopySize,
32
33    #[error("previous object is still in use")]
34    ValueGuardInUse,
35
36    #[error("i/o error during object operation: {0}")]
37    Io(#[from] io::Error),
38
39    #[error("missing hash table")]
40    MissingHashTable,
41
42    #[error("missing object from hash table")]
43    MissingObjectFromHashTable,
44
45    #[error("invalid offset array offset")]
46    InvalidOffsetArrayOffset,
47
48    #[error("invalid offset array index")]
49    InvalidOffsetArrayIndex,
50
51    #[error("empty offset array list")]
52    EmptyOffsetArrayList,
53
54    #[error("empty offset array node")]
55    EmptyOffsetArrayNode,
56
57    #[error("empty inline cursor")]
58    EmptyInlineCursor,
59
60    #[error("unset cursor")]
61    UnsetCursor,
62
63    #[error("malformed filter")]
64    MalformedFilter,
65
66    #[error("Invalid field")]
67    InvalidField,
68
69    #[error("Decompressor error")]
70    DecompressorError,
71
72    #[error("out of bounds index")]
73    OutOfBoundsIndex,
74
75    #[error("invalid offset")]
76    InvalidOffset,
77
78    #[error("zerocopy failure")]
79    ZerocopyFailure,
80
81    #[error("misaligned object offset: {0:#x}")]
82    MisalignedOffset(u64),
83
84    #[error("sigbus handler error")]
85    SigbusHandlerError,
86
87    #[error("unknown compression method")]
88    UnknownCompressionMethod,
89
90    #[error("uuid encoding/decoding")]
91    UuidSerde,
92
93    #[error("invalid filename")]
94    InvalidFilename,
95
96    #[error("directory not found")]
97    DirectoryNotFound,
98
99    #[error("not a directory")]
100    NotADirectory,
101
102    #[error("invalid query configuration")]
103    InvalidQueryConfiguration,
104
105    #[error("FSS verification error")]
106    FssVerificationError,
107}
108
109static_assertions::const_assert!(std::mem::size_of::<JournalError>() <= 16);
110
111impl<T: zerocopy::KnownLayout> From<zerocopy::SizeError<&[u8], T>> for JournalError {
112    fn from(_: zerocopy::SizeError<&[u8], T>) -> Self {
113        JournalError::InvalidZeroCopySize
114    }
115}
116
117pub type Result<T> = std::result::Result<T, JournalError>;