distributed_lock_core/
error.rs

1//! Error types for distributed lock operations.
2
3use std::time::Duration;
4use thiserror::Error;
5
6/// Errors that can occur during lock operations.
7#[derive(Error, Debug)]
8pub enum LockError {
9    /// Lock acquisition timed out.
10    #[error("lock acquisition timed out after {0:?}")]
11    Timeout(Duration),
12
13    /// Lock operation was cancelled.
14    #[error("lock operation was cancelled")]
15    Cancelled,
16
17    /// Deadlock detected (e.g., same connection already holds lock).
18    #[error("deadlock detected: {0}")]
19    Deadlock(String),
20
21    /// Backend connection failed.
22    #[error("connection error: {0}")]
23    Connection(#[source] Box<dyn std::error::Error + Send + Sync>),
24
25    /// Lock was lost after acquisition (e.g., connection died).
26    #[error("lock was lost: {0}")]
27    LockLost(String),
28
29    /// Invalid lock name.
30    #[error("invalid lock name: {0}")]
31    InvalidName(String),
32
33    /// Backend-specific error.
34    #[error("backend error: {0}")]
35    Backend(#[source] Box<dyn std::error::Error + Send + Sync>),
36}
37
38/// Result type for lock operations.
39pub type LockResult<T> = Result<T, LockError>;