Skip to main content

hitchmark_core/
error.rs

1//! Error types for hitchmark-core.
2
3use thiserror::Error;
4
5/// Hitchmark result type.
6pub type Result<T> = std::result::Result<T, Error>;
7
8/// Error types.
9#[derive(Error, Debug)]
10pub enum Error {
11    /// Invalid hook:// URI
12    #[error("Invalid URI: {0}")]
13    InvalidUri(String),
14
15    /// Purple ID error
16    #[error("Purple ID error: {0}")]
17    PurpleError(String),
18
19    /// Database error
20    #[error("Database error: {0}")]
21    DatabaseError(#[from] rusqlite::Error),
22
23    /// I/O error
24    #[error("I/O error: {0}")]
25    Io(#[from] std::io::Error),
26
27    /// Link already exists between the two URIs
28    #[error("Link already exists between {uri_a} and {uri_b}")]
29    LinkAlreadyExists {
30        /// First URI in the existing link
31        uri_a: String,
32        /// Second URI in the existing link
33        uri_b: String,
34    },
35
36    /// Bookmark with this UUID already exists in the store
37    #[error("Bookmark '{id}' already exists in the store")]
38    BookmarkAlreadyExists {
39        /// The conflicting bookmark UUID
40        id: String,
41    },
42
43    /// Database schema version mismatch — database was created by a newer version
44    #[error("Database schema version {found} is newer than supported version {supported}. Please upgrade hitchmark.")]
45    SchemaTooNew {
46        /// Schema version found in the database
47        found: u32,
48        /// Maximum schema version this build supports
49        supported: u32,
50    },
51
52    /// Other errors
53    #[error("{0}")]
54    Other(String),
55}