Skip to main content

alvan_lic/
error.rs

1//! Error types for the alvan-lic crate
2
3use thiserror::Error;
4
5/// Result type alias for license operations
6pub type Result<T> = std::result::Result<T, LicenseError>;
7
8/// Errors that can occur during license generation or validation
9#[derive(Error, Debug)]
10pub enum LicenseError {
11    /// The license key has an invalid format
12    #[error("Invalid license format")]
13    InvalidFormat,
14
15    /// The license key signature is invalid
16    #[error("Invalid license signature")]
17    InvalidSignature,
18
19    /// The license has expired
20    #[error("License has expired")]
21    Expired,
22
23    /// The license data is corrupted or invalid
24    #[error("Invalid license data: {0}")]
25    InvalidData(String),
26
27    /// Base64 decoding error
28    #[error("Base64 decoding error: {0}")]
29    Base64Error(#[from] base64::DecodeError),
30
31    /// Chrono parsing error
32    #[error("Time parsing error: {0}")]
33    ChronoError(#[from] chrono::ParseError),
34}