clawdentity_core/
error.rs1use std::path::PathBuf;
2
3use thiserror::Error;
4
5pub type Result<T> = std::result::Result<T, CoreError>;
6
7#[derive(Debug, Error)]
8pub enum CoreError {
9 #[error("unable to resolve home directory")]
10 HomeDirectoryUnavailable,
11 #[error("invalid input: {0}")]
12 InvalidInput(String),
13 #[error("invalid url for {context}: {value}")]
14 InvalidUrl {
15 context: &'static str,
16 value: String,
17 },
18 #[error("invalid config key: {0}")]
19 InvalidConfigKey(String),
20 #[error("identity already exists at {0}")]
21 IdentityAlreadyExists(PathBuf),
22 #[error("identity is not initialized at {0}")]
23 IdentityNotFound(PathBuf),
24 #[error("base64 decode failed: {0}")]
25 Base64Decode(String),
26 #[error("http request failed: {0}")]
27 Http(String),
28 #[error("unexpected http status {status}: {message}")]
29 HttpStatus { status: u16, message: String },
30 #[error("io error at {path}: {source}")]
31 Io {
32 path: PathBuf,
33 #[source]
34 source: std::io::Error,
35 },
36 #[error("failed to parse json at {path}: {source}")]
37 JsonParse {
38 path: PathBuf,
39 #[source]
40 source: serde_json::Error,
41 },
42 #[error("failed to serialize json: {0}")]
43 JsonSerialize(#[from] serde_json::Error),
44 #[error("sqlite error: {0}")]
45 Sqlite(#[from] rusqlite::Error),
46}