1use std::path::PathBuf;
4use thiserror::Error;
5
6#[derive(Error, Debug)]
8pub enum DbError {
9 #[error("SQLite error: {0}")]
11 Sqlite(#[from] rusqlite::Error),
12
13 #[error("connection pool error: {0}")]
15 Pool(#[from] r2d2::Error),
16
17 #[error("I/O error: {0}")]
19 Io(#[from] std::io::Error),
20
21 #[error("record not found: {0}")]
23 NotFound(String),
24
25 #[error("database not initialized - run 'uls update' first")]
27 NotInitialized,
28
29 #[error("schema version mismatch: expected {expected}, found {found}")]
31 SchemaVersionMismatch { expected: i32, found: i32 },
32
33 #[error("database file not found: {0}")]
35 FileNotFound(PathBuf),
36
37 #[error("invalid data: {0}")]
39 InvalidData(String),
40
41 #[error("transaction error: {0}")]
43 Transaction(String),
44
45 #[error("parser error: {0}")]
47 Parser(#[from] uls_parser::ParseError),
48
49 #[error("zip error: {0}")]
51 Zip(#[from] uls_parser::archive::ZipError),
52}
53
54pub type Result<T> = std::result::Result<T, DbError>;