talos/
errors.rs

1// src/errors.rs
2
3use std::result;
4
5use thiserror::Error;
6
7use crate::client::errors::ClientApiError;
8
9/// Convenient alias for results throughout Talos.
10pub type LicenseResult<T> = result::Result<T, LicenseError>;
11
12/// Central error type for license-related operations.
13///
14/// This is used by both the client and the server side of Talos.
15/// HTTP mapping / printing / logging should be done *outside* this type.
16#[derive(Debug, Error)]
17pub enum LicenseError {
18    /// The server responded with an application-level error.
19    #[error("server error: {0}")]
20    ServerError(String),
21
22    /// The license is invalid for the requested operation.
23    #[error("license invalid: {0}")]
24    InvalidLicense(String),
25
26    /// Network / HTTP client errors when talking to the licensing server.
27    #[error("network error: {0}")]
28    NetworkError(#[from] reqwest::Error),
29
30    /// Local storage errors (filesystem, OS I/O, etc.).
31    #[error("storage error: {0}")]
32    StorageError(#[from] std::io::Error),
33
34    /// Errors during encryption (wrong key, algorithm failure, etc.).
35    #[error("encryption error: {0}")]
36    EncryptionError(String),
37
38    /// Errors during decryption (corrupted ciphertext, wrong key, etc.).
39    #[error("decryption error: {0}")]
40    DecryptionError(String),
41
42    /// Errors when accessing the OS keyring/credential store.
43    #[error("keyring error: {0}")]
44    KeyringError(String),
45
46    /// Configuration-related errors (missing values, invalid formats, etc.).
47    #[error("config error: {0}")]
48    ConfigError(String),
49
50    /// Structured API error from the license server.
51    ///
52    /// This wraps the server's error response with machine-readable error codes
53    /// for programmatic error handling.
54    #[error("api error: {0}")]
55    ClientApiError(ClientApiError),
56
57    /// Fallback for unexpected conditions that don't fit other variants.
58    #[error("unknown error")]
59    UnknownError,
60}