Skip to main content

vwh_core/
error.rs

1use thiserror::Error;
2
3pub type Result<T> = std::result::Result<T, Error>;
4
5#[derive(Error, Debug)]
6pub enum Error {
7    #[error("Invalid magic bytes (expected VWH\\0)")]
8    InvalidMagic,
9
10    #[error("Unsupported version: {0}")]
11    UnsupportedVersion(u16),
12
13    #[error("Invalid intent value: {0}")]
14    InvalidIntent(u8),
15
16    #[error("Invalid intent string: {0}")]
17    InvalidIntentString(String),
18
19    #[error("Invalid artifact ID")]
20    InvalidArtifactId,
21
22    #[error("Invalid hex encoding")]
23    InvalidHex,
24
25    #[error("Signature verification failed")]
26    SignatureInvalid,
27
28    #[error("File too small (minimum {expected} bytes, got {actual})")]
29    FileTooSmall { expected: usize, actual: usize },
30
31    #[error("Unexpected EOF while reading {field}")]
32    UnexpectedEof { field: String },
33
34    #[error("IO error: {0}")]
35    Io(#[from] std::io::Error),
36
37    #[error("JSON error: {0}")]
38    Json(#[from] serde_json::Error),
39}
40