1use std::fmt::Debug;
2use thiserror::Error;
3
4#[derive(Error, Debug, PartialEq, Eq, Hash, Clone, Copy)]
8#[error("The lock with the key `{key:?}` couldn't be acquired because another thread panicked while holding this lock")]
9pub struct PoisonError<K, G> {
10 pub key: K,
12 pub(super) guard: G,
13}
14
15#[derive(Error, Debug, PartialEq, Eq, Hash, Clone, Copy)]
17pub enum UnpoisonError {
18 #[error("Tried to unpoison a lock that wasn't poisoned")]
20 NotPoisoned,
21
22 #[error("At least one other thread is currently blocked on this mutex, we cannot unpoison it")]
24 OtherThreadsBlockedOnMutex,
25}
26
27#[derive(Error, Debug, PartialEq, Eq, Hash, Clone, Copy)]
29pub enum TryLockError<K, G> {
30 #[error(transparent)]
32 Poisoned(PoisonError<K, G>),
33
34 #[error(
36 "The lock could not be acquired at this time because the operation would otherwise block"
37 )]
38 WouldBlock,
39}