ave_bridge/error.rs
1use thiserror::Error;
2
3use ave_core::error::Error as CoreError;
4use ave_core::helpers::sink::SinkError;
5
6/// Bridge API errors.
7///
8/// These errors wrap core errors and add bridge-specific error types
9/// for input validation, key management, and configuration.
10#[derive(Debug, Clone, Error)]
11pub enum BridgeError {
12 // ========================================
13 // Core Errors (propagated from Ave core)
14 // ========================================
15 /// An error originated in the core layer.
16 #[error(transparent)]
17 Core(#[from] CoreError),
18
19 // ========================================
20 // Input Validation Errors
21 // ========================================
22 /// The provided subject identifier is not valid.
23 #[error("Invalid subject identifier: {0}")]
24 InvalidSubjectId(String),
25
26 /// The provided request identifier is not valid.
27 #[error("Invalid request identifier: {0}")]
28 InvalidRequestId(String),
29
30 /// The provided public key is not valid.
31 #[error("Invalid public key: {0}")]
32 InvalidPublicKey(String),
33
34 /// The provided signature is not valid.
35 #[error("Invalid signature: {0}")]
36 InvalidSignature(String),
37
38 // ========================================
39 // Key Management Errors
40 // ========================================
41 /// Failed to create the keys directory.
42 #[error("Failed to create keys directory: {0}")]
43 KeyDirectoryCreation(String),
44
45 /// Failed to read the private key file.
46 #[error("Failed to read private key: {0}")]
47 KeyRead(String),
48
49 /// Failed to decrypt the private key. Usually indicates a wrong password.
50 #[error("Failed to decrypt private key: ensure your password is correct")]
51 KeyDecrypt(String),
52
53 /// Failed to create a key pair from the stored key material.
54 #[error("Failed to restore key pair: {0}")]
55 KeyRestore(String),
56
57 /// Failed to generate a new key pair.
58 #[error("Failed to generate key pair: {0}")]
59 KeyGeneration(String),
60
61 /// Failed to encrypt the private key for storage.
62 #[error("Failed to encrypt private key: {0}")]
63 KeyEncrypt(String),
64
65 /// Failed to write the private key file.
66 #[error("Failed to store private key: {0}")]
67 KeyWrite(String),
68
69 // ========================================
70 // Configuration Errors
71 // ========================================
72 /// Failed to build the configuration from the provided sources.
73 #[error("Failed to build configuration: {0}")]
74 ConfigBuild(String),
75
76 /// Failed to deserialize the configuration file.
77 #[error("Invalid configuration format: {0}")]
78 ConfigDeserialize(String),
79
80 // ========================================
81 // Conversion Errors
82 // ========================================
83 /// The event request could not be converted to the internal format.
84 #[error("Invalid event request format: {0}")]
85 InvalidEventRequest(String),
86
87 // ========================================
88 // Sink Authentication Errors
89 // ========================================
90 /// Sink authentication failed during initialization.
91 #[error("Sink authentication failed: {0}")]
92 SinkAuth(#[from] SinkError),
93}