four_word_networking/
error.rs1use thiserror::Error;
4
5pub type Result<T> = std::result::Result<T, FourWordError>;
7
8#[derive(Error, Debug)]
10pub enum FourWordError {
11 #[error("Invalid word address format: {0}")]
12 InvalidFourWordAddress(String),
13
14 #[error("Word not found in dictionary: {0}")]
15 WordNotFound(String),
16
17 #[error("Dictionary position out of range: {0}")]
18 PositionOutOfRange(usize),
19
20 #[error("Numeric suffix out of range: {0}")]
21 NumericSuffixOutOfRange(u32),
22
23 #[error("Invalid input: {0}")]
24 InvalidInput(String),
25
26 #[error("Compression error: {0}")]
27 CompressionError(String),
28
29 #[error("Decompression error: {0}")]
30 DecompressionError(String),
31
32 #[error("IO error: {0}")]
33 Io(#[from] std::io::Error),
34
35 #[error("Serialization error: {0}")]
36 Serialization(#[from] serde_json::Error),
37
38 #[error("Encoding error: {0}")]
39 EncodingError(String),
40
41 #[error("Decoding error: {0}")]
42 DecodingError(String),
43
44 #[error("Dictionary error: {0}")]
45 DictionaryError(String),
46
47 #[error("Invalid word: {0}")]
48 InvalidWord(String),
49
50 #[error("Invalid word index: {0}")]
51 InvalidWordIndex(u16),
52
53 #[error("Invalid word count: expected {expected}, got {actual}")]
54 InvalidWordCount { expected: usize, actual: usize },
55}