ricecoder_keybinds/
error.rs1use thiserror::Error;
4
5#[derive(Debug, Error)]
7pub enum ParseError {
8 #[error("Invalid JSON syntax: {0}")]
9 InvalidJson(String),
10
11 #[error("Invalid Markdown syntax: {0}")]
12 InvalidMarkdown(String),
13
14 #[error("Missing required field: {0}")]
15 MissingField(String),
16
17 #[error("Invalid key syntax: {0}")]
18 InvalidKeySyntax(String),
19
20 #[error("Invalid modifier: {0}")]
21 InvalidModifier(String),
22
23 #[error("Duplicate keybind definition: {0}")]
24 DuplicateDefinition(String),
25
26 #[error("Parse error at line {line}: {message}")]
27 LineError { line: usize, message: String },
28}
29
30#[derive(Debug, Error)]
32pub enum RegistryError {
33 #[error("Duplicate action ID: {0}")]
34 DuplicateActionId(String),
35
36 #[error("Invalid action ID format: {0}")]
37 InvalidActionIdFormat(String),
38
39 #[error("Action not found: {0}")]
40 ActionNotFound(String),
41
42 #[error("Key combination not found")]
43 KeyNotFound,
44}
45
46#[derive(Debug, Error)]
48pub enum ProfileError {
49 #[error("Profile not found: {0}")]
50 ProfileNotFound(String),
51
52 #[error("Profile already exists: {0}")]
53 ProfileAlreadyExists(String),
54
55 #[error("Cannot delete active profile: {0}")]
56 CannotDeleteActiveProfile(String),
57
58 #[error("Invalid profile name: {0}")]
59 InvalidProfileName(String),
60
61 #[error("No active profile set")]
62 NoActiveProfile,
63}
64
65#[derive(Debug, Error)]
67pub enum EngineError {
68 #[error("Registry error: {0}")]
69 RegistryError(#[from] RegistryError),
70
71 #[error("Profile error: {0}")]
72 ProfileError(#[from] ProfileError),
73
74 #[error("Parse error: {0}")]
75 ParseError(#[from] ParseError),
76
77 #[error("Persistence error: {0}")]
78 PersistenceError(#[from] PersistenceError),
79
80 #[error("No keybind for action: {0}")]
81 NoKeybindForAction(String),
82
83 #[error("Invalid key combination")]
84 InvalidKeyCombo,
85
86 #[error("Engine not initialized")]
87 NotInitialized,
88
89 #[error("Defaults load error: {0}")]
90 DefaultsLoadError(String),
91}
92
93#[derive(Debug, Error)]
95pub enum PersistenceError {
96 #[error("File not found: {0}")]
97 FileNotFound(String),
98
99 #[error("Permission denied: {0}")]
100 PermissionDenied(String),
101
102 #[error("Corrupted JSON: {0}")]
103 CorruptedJson(String),
104
105 #[error("IO error: {0}")]
106 IoError(#[from] std::io::Error),
107
108 #[error("Serialization error: {0}")]
109 SerializationError(String),
110
111 #[error("Deserialization error: {0}")]
112 DeserializationError(String),
113
114 #[error("Profile not found: {0}")]
115 ProfileNotFound(String),
116}