claw_core/error.rs
1use thiserror::Error;
2
3/// Errors returned by core object encoding, IDs, and schema conversion.
4#[derive(Debug, Error)]
5pub enum CoreError {
6 /// COF bytes did not start with the expected magic prefix.
7 #[error("invalid magic bytes")]
8 InvalidMagic,
9 /// COF bytes use a version this crate cannot read.
10 #[error("unsupported COF version: {0}")]
11 UnsupportedVersion(u8),
12 /// COF bytes used an unknown object type tag.
13 #[error("unknown type tag: {0}")]
14 UnknownTypeTag(u8),
15 /// CRC32 in the COF trailer did not match the decoded payload.
16 #[error("CRC32 mismatch: expected {expected:#010x}, got {actual:#010x}")]
17 Crc32Mismatch {
18 /// CRC32 value recorded in the object.
19 expected: u32,
20 /// CRC32 computed from the decoded payload.
21 actual: u32,
22 },
23 /// Decompression failed while decoding object bytes.
24 #[error("decompression error: {0}")]
25 Decompression(String),
26 /// Compression failed while encoding object bytes.
27 #[error("compression error: {0}")]
28 Compression(String),
29 /// Serialization to a stable wire representation failed.
30 #[error("serialization error: {0}")]
31 Serialization(String),
32 /// Deserialization from a stable wire representation failed.
33 #[error("deserialization error: {0}")]
34 Deserialization(String),
35 /// Object ID text or bytes were malformed.
36 #[error("invalid object ID: {0}")]
37 InvalidObjectId(String),
38 /// Tree entry name failed canonical path validation.
39 #[error("invalid tree entry name: {0}")]
40 InvalidTreeEntryName(String),
41 /// Payload exceeded a configured object-size limit.
42 #[error("payload too large: {size} bytes (max {max})")]
43 PayloadTooLarge {
44 /// Actual payload size in bytes.
45 size: usize,
46 /// Configured maximum payload size in bytes.
47 max: usize,
48 },
49 /// Filesystem or stream I/O failed.
50 #[error("io error: {0}")]
51 Io(#[from] std::io::Error),
52}