atproto_jetstream/errors.rs
1//! # Structured Error Types for AT Protocol Jetstream
2//!
3//! Error handling for WebSocket-based event streaming operations using the AT Protocol Jetstream service.
4//! All errors follow the project convention of prefixed error codes with descriptive messages.
5//!
6//! ## Error Categories
7//!
8//! - **`ConsumerError`** (consumer-1 to consumer-9): Errors related to WebSocket connections, message processing, and event handling
9//!
10//! ## Error Format
11//!
12//! All errors use the standardized format: `error-atproto-jetstream-{domain}-{number} {message}: {details}`
13
14use thiserror::Error;
15
16/// Errors that can occur when consuming events from the Jetstream service
17#[derive(Error, Debug)]
18pub enum ConsumerError {
19 /// Occurs when WebSocket connection establishment or maintenance fails
20 #[error("error-atproto-jetstream-consumer-1 WebSocket connection failed: {0}")]
21 ConnectionFailed(String),
22
23 /// Occurs when message decompression using zstd dictionary fails
24 #[error("error-atproto-jetstream-consumer-2 Message decompression failed: {0}")]
25 DecompressionFailed(String),
26
27 /// Occurs when deserializing Jetstream events from JSON fails
28 #[error("error-atproto-jetstream-consumer-3 Event deserialization failed: {0}")]
29 DeserializationFailed(String),
30
31 /// Occurs when attempting to register event handlers after consumer has started
32 #[error("error-atproto-jetstream-consumer-4 Handler registration failed: {0}")]
33 HandlerRegistrationFailed(String),
34
35 /// Occurs when event sender channel is not properly initialized
36 #[error("error-atproto-jetstream-consumer-5 Event sender not initialized: {0}")]
37 EventSenderNotInitialized(String),
38
39 /// Occurs when converting WebSocket messages to expected format fails
40 #[error("error-atproto-jetstream-consumer-6 Message conversion failed: {0}")]
41 MessageConversionFailed(String),
42
43 /// Occurs when serializing update messages for transmission fails
44 #[error("error-atproto-jetstream-consumer-7 Update serialization failed: {0}")]
45 UpdateSerializationFailed(String),
46
47 /// Occurs when sending updates through WebSocket connection fails
48 #[error("error-atproto-jetstream-consumer-8 Update send failed: {0}")]
49 UpdateSendFailed(String),
50
51 /// Occurs when creating zstd decompressor with dictionary fails
52 #[error("error-atproto-jetstream-consumer-9 Decompressor creation failed: {0}")]
53 DecompressorCreationFailed(String),
54}