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