1use crate::types::HotkeyId;
2use thiserror::Error;
3
4#[derive(Debug, Error)]
5pub enum Error {
6 #[error("IO error: {0}")]
7 Io(#[from] std::io::Error),
8
9 #[error("Accessibility permission not granted. Please enable it in System Settings > Privacy & Security > Accessibility")]
10 AccessibilityNotGranted,
11
12 #[error("Failed to create event tap: {0}")]
13 EventTapCreationFailed(String),
14
15 #[error("Failed to create run loop source")]
16 RunLoopSourceCreationFailed,
17
18 #[error("Hotkey with id {0:?} not found")]
19 HotkeyNotFound(HotkeyId),
20
21 #[error("Hotkey already registered: {0}")]
22 HotkeyAlreadyRegistered(String),
23
24 #[error("Event loop not running")]
25 EventLoopNotRunning,
26
27 #[error("Operation timed out")]
28 Timeout,
29
30 #[error("Failed to start recording")]
31 RecordingFailed,
32
33 #[error("Platform error: {0}")]
34 Platform(String),
35
36 #[error("Hotkey cannot be empty (must have at least a key or modifiers)")]
37 EmptyHotkey,
38
39 #[error("Invalid hotkey format: {0}")]
40 InvalidHotkeyFormat(String),
41
42 #[error("Unknown key: {0}")]
43 UnknownKey(String),
44
45 #[error("Unknown modifier: {0}")]
46 UnknownModifier(String),
47
48 #[error("Internal error: Mutex poisoned")]
49 MutexPoisoned,
50}
51
52pub type Result<T> = std::result::Result<T, Error>;