Skip to main content

bonds_core/
error.rs

1use thiserror::Error;
2
3/// Errors surfaced by the API
4#[derive(Error, Debug)]
5pub enum BondError {
6    /// Filesystem or OS I/O failure.
7    #[error("IO error: {0}")]
8    Io(#[from] std::io::Error),
9
10    /// SQLite query/connection failure.
11    #[error("SQLite error: {0}")]
12    Sqlite(#[from] rusqlite::Error),
13
14    /// JSON serialization/deserialization failure.
15    #[error("Serialization error: {0}")]
16    Serde(#[from] serde_json::Error),
17
18    /// A conflicting bond record already exists.
19    #[error("Bond already exists")]
20    AlreadyExists,
21
22    /// The requested target path already exists and cannot be replaced.
23    #[error("Target already exists: {0}")]
24    TargetExists(String),
25
26    /// No bond matched the provided identifier.
27    #[error("Bond not found: {0}")]
28    NotFound(String),
29
30    /// A provided path is invalid or unusable.
31    #[error("Invalid path: {0}")]
32    InvalidPath(String),
33
34    /// Configuration file parse or write error.
35    #[error("config error: {0}")]
36    Config(String),
37
38    /// The identifier prefix matched more than one bond.
39    #[error("ambiguous identifier '{0}': use more characters")]
40    AmbiguousId(String),
41
42    /// Failed to parse or interpret a timestamp.
43    #[error("invalid timestamp: {0}")]
44    InvalidTimestamp(String),
45}