mirror of
https://github.com/block/buzz.git
synced 2026-08-18 06:50:31 +02:00
Signed-off-by: Will Pfleger <pfleger.will@gmail.com> Signed-off-by: Will Pfleger <wpfleger@block.xyz> Signed-off-by: Will Pfleger <wpfleger@squareup.com> Signed-off-by: Will Pfleger <wpfleger96@gmail.com> Co-authored-by: npub1mn7jgtj4w2pd0g0zeuhxsa6jy6p0rewxz4kujt98my82ahfmp72sxjexk7 <dcfd242e557282d7a1e2cf2e6877522682f1e5c6156dc92ca7d90eaedd3b0f95@sprout-oss.stage.blox.sqprod.co> Co-authored-by: npub1fgdl5qqnh3k3f2xkqrvt7cujalhm623x4s7fdjdj5yrtp5fzjl9qrjpucw <4a1bfa0013bc6d14a8d600d8bf6392efefbd2a26ac3c96c9b2a106b0d12297ca@sprout-oss.stage.blox.sqprod.co> Co-authored-by: npub16v54tttfqacx9ycvc3k0ut0npj564ahcuajzy6qjvh57ntmsf4uq4806j2 <d32955ad69077062930cc46cfe2df30ca9aaf6f8e76422681265e9e9af704d78@sprout-oss.stage.blox.sqprod.co> Co-authored-by: Will Pfleger <wpfleger96@gmail.com>
39 lines
1.3 KiB
Rust
39 lines
1.3 KiB
Rust
use thiserror::Error;
|
|
|
|
/// Errors that can occur in pub/sub, presence, and typing operations.
|
|
#[derive(Debug, Error)]
|
|
pub enum PubSubError {
|
|
/// A Redis command failed.
|
|
#[error("Redis error: {0}")]
|
|
Redis(#[from] redis::RedisError),
|
|
|
|
/// Failed to acquire a connection from the Redis pool.
|
|
#[error("Redis pool error: {0}")]
|
|
Pool(#[from] deadpool_redis::PoolError),
|
|
|
|
/// JSON serialization or deserialization failed.
|
|
#[error("Serialization error: {0}")]
|
|
Serialization(#[from] serde_json::Error),
|
|
|
|
/// The broadcast receiver fell behind and dropped messages.
|
|
#[error("Broadcast receiver lagged: {0} messages dropped")]
|
|
BroadcastLagged(u64),
|
|
|
|
/// The pub/sub subscriber task has stopped unexpectedly.
|
|
#[error("Pub/sub subscriber task stopped")]
|
|
SubscriberStopped,
|
|
|
|
/// A Redis channel key could not be parsed as a valid channel ID.
|
|
#[error("Invalid channel key: {0}")]
|
|
InvalidChannelKey(String),
|
|
}
|
|
|
|
impl From<tokio::sync::broadcast::error::RecvError> for PubSubError {
|
|
fn from(e: tokio::sync::broadcast::error::RecvError) -> Self {
|
|
match e {
|
|
tokio::sync::broadcast::error::RecvError::Lagged(n) => PubSubError::BroadcastLagged(n),
|
|
tokio::sync::broadcast::error::RecvError::Closed => PubSubError::SubscriberStopped,
|
|
}
|
|
}
|
|
}
|