1use thiserror::Error;
7
8#[derive(Error, Debug)]
10pub enum StorageError {
11 #[error("Could not find data directory")]
13 NoDataDir,
14
15 #[error("Could not locate config directory")]
17 NoConfigDir,
18
19 #[error("IO error: {0}")]
21 Io(#[from] std::io::Error),
22
23 #[error("JSON error: {0}")]
25 Json(#[from] serde_json::Error),
26
27 #[error("Text attachment is not valid UTF-8: {0}")]
29 InvalidUtf8(#[from] std::str::Utf8Error),
30
31 #[error("Empty image data")]
33 EmptyImage,
34
35 #[error("Invalid hash format")]
37 InvalidHash,
38
39 #[error("Invalid document conversion: {0}")]
41 InvalidDocumentConversion(String),
42
43 #[error("Image not found: {0}")]
45 ImageNotFound(String),
46
47 #[error("Thread not found: {0}")]
49 ThreadNotFound(String),
50
51 #[error("Workspace not found: {0}")]
53 WorkspaceNotFound(String),
54
55 #[error("Invalid workspace name")]
57 InvalidWorkspaceName,
58
59 #[error("Invalid workspace path: {0}")]
61 InvalidWorkspacePath(String),
62
63 #[error("Invalid thread message: {0}")]
65 InvalidThreadMessage(String),
66
67 #[error("Profile not found: {0}")]
69 ProfileNotFound(String),
70
71 #[error("Cannot delete the last profile")]
73 CannotDeleteLastProfile,
74
75 #[error("Invalid profile ID: {0}")]
77 InvalidProfileId(String),
78
79 #[error("{0}")]
81 AuthState(String),
82
83 #[error("{0}")]
85 KeyStore(String),
86
87 #[error("Unsupported OCR model id: {0}")]
89 InvalidOcrModel(String),
90}
91
92pub type Result<T> = std::result::Result<T, StorageError>;