phala_tee_deploy_rs/error.rs
1use thiserror::Error;
2
3/// Error types for the Phala TEE deployment library.
4///
5/// This module defines a comprehensive error type hierarchy for handling
6/// various error conditions that may occur during TEE deployments.
7#[derive(Error, Debug)]
8pub enum Error {
9 /// Errors from the underlying HTTP client library.
10 ///
11 /// This variant wraps errors from the reqwest library, which include
12 /// network connectivity issues, timeouts, and TLS/SSL errors.
13 #[error("HTTP client error: {0}")]
14 HttpClient(#[from] reqwest::Error),
15
16 /// Configuration-related errors.
17 ///
18 /// These errors occur when the provided configuration is invalid,
19 /// such as malformed Docker Compose files or invalid VM settings.
20 #[error("Invalid configuration: {0}")]
21 Configuration(String),
22
23 /// Encryption-related errors.
24 ///
25 /// These errors occur during the encryption or decryption of
26 /// sensitive data, such as environment variables.
27 #[error("Encryption error: {0}")]
28 Encryption(String),
29
30 /// API response errors from the Phala Cloud API.
31 ///
32 /// These errors include status codes and error messages directly
33 /// from the API, such as authentication failures or resource limitations.
34 #[error("API error: {status_code} - {message}")]
35 Api { status_code: u16, message: String },
36
37 /// Missing environment variable errors.
38 ///
39 /// These errors occur when a required environment variable is not set
40 /// in the current environment.
41 #[error("Missing required environment variable: {0}")]
42 MissingEnvVar(String),
43
44 /// Invalid key format errors.
45 ///
46 /// These errors occur when a cryptographic key is malformed or
47 /// in an unexpected format.
48 #[error("Invalid key format: {0}")]
49 InvalidKey(String),
50
51 /// Serialization errors.
52 ///
53 /// These errors occur when serializing or deserializing data.
54 #[error("Serialization error: {0}")]
55 Serialization(String),
56}