dampen_dev/persistence/error.rs
1use std::path::PathBuf;
2
3/// Error type for window persistence operations.
4#[derive(Debug, thiserror::Error)]
5pub enum PersistenceError {
6 /// Failed to determine the configuration directory for the application.
7 #[error("Failed to determine config directory for app '{app_name}'")]
8 NoConfigDir {
9 /// The application name that was used.
10 app_name: String,
11 },
12
13 /// Failed to create the configuration directory.
14 #[error("Failed to create config directory '{path}': {source}")]
15 CreateDirFailed {
16 /// Path to the directory.
17 path: PathBuf,
18 /// Underlying I/O error.
19 #[source]
20 source: std::io::Error,
21 },
22
23 /// Failed to read the configuration file.
24 #[error("Failed to read config file '{path}': {source}")]
25 ReadFailed {
26 /// Path to the file.
27 path: PathBuf,
28 /// Underlying I/O error.
29 #[source]
30 source: std::io::Error,
31 },
32
33 /// Failed to write the configuration file.
34 #[error("Failed to write config file '{path}': {source}")]
35 WriteFailed {
36 /// Path to the file.
37 path: PathBuf,
38 /// Underlying I/O error.
39 #[source]
40 source: std::io::Error,
41 },
42
43 /// Failed to parse the configuration file (JSON error).
44 #[error("Failed to parse config file '{path}': {source}")]
45 ParseFailed {
46 /// Path to the file.
47 path: PathBuf,
48 /// Underlying JSON parse error.
49 #[source]
50 source: serde_json::Error,
51 },
52
53 /// The window state contains invalid values (e.g. dimensions too small).
54 #[error("Invalid window state: {reason}")]
55 InvalidState {
56 /// Description of why the state is invalid.
57 reason: String,
58 },
59}