use std::path::PathBuf;
use thiserror::Error;
#[derive(Debug, Error)]
pub enum GetMyIdError {
#[error("failed to connect to socket at {path}: {source}")]
ConnectionFailed {
path: PathBuf,
#[source]
source: std::io::Error,
},
#[error("failed to read response: {0}")]
ReadError(#[source] std::io::Error),
#[error("failed to write to socket: {0}")]
WriteError(#[source] std::io::Error),
#[error("invalid JSON response: {0}")]
InvalidJson(#[source] serde_json::Error),
#[error("daemon error ({code}): {message}")]
DaemonError {
code: String,
message: String,
},
#[error("invalid response: missing field '{field}'")]
MissingField {
field: &'static str,
},
#[error("socket path does not exist: {0}")]
SocketNotFound(PathBuf),
#[error("connection timeout after {0:?}")]
Timeout(std::time::Duration),
}
pub type Result<T> = std::result::Result<T, GetMyIdError>;