Rust · 975 bytes Raw Blame History
1 use std::path::PathBuf;
2 use thiserror::Error;
3
4 #[derive(Debug, Error)]
5 pub enum CoreError {
6 #[error("I/O error at {path:?}: {source}")]
7 Io {
8 path: PathBuf,
9 #[source]
10 source: std::io::Error,
11 },
12
13 #[error("I/O error: {0}")]
14 PlainIo(#[from] std::io::Error),
15
16 #[error("JSON parse error at {path:?}:{line}: {source}")]
17 Json {
18 path: PathBuf,
19 line: usize,
20 #[source]
21 source: serde_json::Error,
22 },
23
24 #[error("JSON error: {0}")]
25 PlainJson(#[from] serde_json::Error),
26
27 #[error("Claude home directory not found (no $HOME)")]
28 HomeNotFound,
29
30 #[error("Projects directory does not exist: {0:?}")]
31 ProjectsDirMissing(PathBuf),
32
33 #[error("Session not found: {0}")]
34 SessionNotFound(String),
35
36 #[error("Project not found: {0}")]
37 ProjectNotFound(String),
38
39 #[error("Walk error: {0}")]
40 Walk(#[from] walkdir::Error),
41 }
42
43 pub type CoreResult<T> = Result<T, CoreError>;
44