1use thiserror::Error;
4
5#[derive(Debug, Error)]
7pub enum DecodeError {
8 #[error("Schema not found for fingerprint {fingerprint}")]
9 SchemaNotFound { fingerprint: String },
10
11 #[error("ABI decode failed: {reason}")]
12 AbiDecodeFailed { reason: String },
13
14 #[error("Type mismatch: expected {expected}, got {got}")]
15 TypeMismatch { expected: String, got: String },
16
17 #[error("Unsupported chain: {chain}")]
18 UnsupportedChain { chain: String },
19
20 #[error("Invalid raw event: {reason}")]
21 InvalidRawEvent { reason: String },
22
23 #[error("Missing required field: {field}")]
24 MissingField { field: String },
25
26 #[error("IO error: {0}")]
27 Io(#[from] std::io::Error),
28
29 #[error("Serialization error: {0}")]
30 Serde(#[from] serde_json::Error),
31
32 #[error("Unknown error: {0}")]
33 Other(String),
34}
35
36#[derive(Debug, Error)]
38pub enum BatchDecodeError {
39 #[error("Batch aborted after {count} errors")]
40 TooManyErrors { count: usize },
41
42 #[error("Decode error at index {index}: {source}")]
43 ItemFailed {
44 index: usize,
45 #[source]
46 source: DecodeError,
47 },
48
49 #[error("Memory limit exceeded: tried to allocate {bytes} bytes")]
50 MemoryLimitExceeded { bytes: usize },
51
52 #[error("{0}")]
53 Other(String),
54}
55
56#[derive(Debug, Error)]
58pub enum RegistryError {
59 #[error("Schema '{name}' v{version} already exists")]
60 AlreadyExists { name: String, version: u32 },
61
62 #[error("Schema '{name}' not found")]
63 NotFound { name: String },
64
65 #[error("Schema validation failed: {reason}")]
66 ValidationFailed { reason: String },
67
68 #[error("Fingerprint mismatch: claimed {claimed}, computed {computed}")]
69 FingerprintMismatch { claimed: String, computed: String },
70
71 #[error("Parse error in CSDL: {0}")]
72 ParseError(String),
73
74 #[error("IO error: {0}")]
75 Io(#[from] std::io::Error),
76
77 #[error("Database error: {0}")]
78 Database(String),
79}
80
81#[derive(Debug, Error)]
83pub enum StreamError {
84 #[error("RPC connection failed: {url}: {reason}")]
85 ConnectionFailed { url: String, reason: String },
86
87 #[error("Stream closed unexpectedly")]
88 Closed,
89
90 #[error("Subscription timeout after {ms}ms")]
91 Timeout { ms: u64 },
92
93 #[error("Decode error in stream: {0}")]
94 Decode(#[from] DecodeError),
95
96 #[error("{0}")]
97 Other(String),
98}