1use thiserror::Error;
2
3#[derive(Debug, Error)]
4pub enum CoreError {
5 #[error("not found: {entity} with id {id}")]
6 NotFound { entity: String, id: String },
7
8 #[error("ambiguous prefix: {prefix} matches {count} {entity} records")]
9 AmbiguousPrefix {
10 entity: String,
11 prefix: String,
12 count: usize,
13 },
14
15 #[error("validation error: {0}")]
16 Validation(String),
17
18 #[error("adapter error: {0} — {1}")]
19 Adapter(String, String),
20
21 #[error("config error: {0}")]
22 Config(String),
23
24 #[error(transparent)]
25 Json(#[from] serde_json::Error),
26
27 #[error(transparent)]
28 Io(#[from] std::io::Error),
29}
30
31pub type Result<T> = std::result::Result<T, CoreError>;