Skip to main content

gen_core/
errors.rs

1use thiserror::Error;
2
3#[derive(Debug, Error, PartialEq)]
4pub enum HashError {
5    #[error("Invalid hex string: {0}")]
6    InvalidHex(#[from] hex::FromHexError),
7    #[error("Hash must be {expected} bytes, got {actual}")]
8    InvalidLength { expected: usize, actual: usize },
9}
10
11#[derive(Debug, Error, PartialEq)]
12pub enum ConfigError {
13    #[error("Failed to find Gen directory")]
14    GenDirectoryNotFound,
15    #[error("Unable to determine repository root")]
16    RepoRootNotFound,
17}
18
19#[derive(Debug, Error, PartialEq)]
20pub enum ConnectionError {
21    #[error("Failed to open database connection: {0}")]
22    OpenFailed(#[from] rusqlite::Error),
23    #[error("Database tracking error: {0}")]
24    DatabaseTracking(String),
25    #[error("Config Error: {0}")]
26    ConfigError(#[from] ConfigError),
27}
28
29#[derive(Debug, Error, PartialEq)]
30pub enum StrandError {
31    #[error("Invalid Strand: {0}")]
32    InvalidStrand(String),
33    #[error("Rusqlite Error: {0}")]
34    SqliteError(#[from] rusqlite::Error),
35}