serenade_lock/error.rs
1//! [`LockError`] variants.
2
3/// Failure while creating or operating a lock.
4#[derive(Debug, thiserror::Error, Clone, PartialEq, Eq)]
5pub enum LockError {
6 /// Resource name is empty or otherwise invalid.
7 #[error("invalid lock key `{key}`: {message}")]
8 InvalidKey {
9 /// Resource that failed validation.
10 key: String,
11 /// Reason text.
12 message: String,
13 },
14 /// Another token already holds the resource.
15 #[error("lock conflict on `{key}`")]
16 Conflict {
17 /// Contended resource.
18 key: String,
19 },
20 /// This token does not currently hold the resource.
21 #[error("lock not held for `{key}`")]
22 NotHeld {
23 /// Resource that was not held.
24 key: String,
25 },
26 /// Token generation failed.
27 #[error("lock token generation failed")]
28 Generation,
29 /// Underlying store failure.
30 #[error("lock store error: {message}")]
31 Store {
32 /// Reason text.
33 message: String,
34 },
35}