1use thiserror::Error;
2
3pub type Result<T> = std::result::Result<T, Error>;
4
5#[derive(Error, Debug)]
6pub enum Error {
7 #[error("Configuration error: {0}")]
8 Config(#[from] config::ConfigError),
9
10 #[error("Database error: {0}")]
11 Database(#[from] fjall::Error),
12
13 #[error("HTTP client error: {0}")]
14 Http(#[from] reqwest::Error),
15
16 #[error("GraphQL error: {0}")]
17 GraphQL(String),
18
19 #[error("JSON parsing error: {0}")]
20 Json(#[from] serde_json::Error),
21
22 #[error("IO error: {0}")]
23 Io(#[from] std::io::Error),
24
25 #[error("Motion API error: {message}")]
26 MotionApi { message: String },
27
28 #[error("Linear API error: {message}")]
29 LinearApi { message: String },
30
31 #[error("Sync error: {0}")]
32 Sync(String),
33
34 #[error("IPC error: {0}")]
35 Ipc(String),
36
37 #[error("Validation error: {0}")]
38 Validation(String),
39
40 #[error("Rate limit exceeded")]
41 RateLimit,
42
43 #[error("Authentication failed")]
44 Authentication,
45
46 #[error("HTTP header error: {0}")]
47 Header(#[from] reqwest::header::InvalidHeaderValue),
48
49 #[error("{0}")]
50 Other(String),
51}
52
53impl From<serde_path_to_error::Error<serde_json::Error>> for Error {
54 fn from(err: serde_path_to_error::Error<serde_json::Error>) -> Self {
55 Error::Json(err.into_inner())
56 }
57}