Skip to main content

sal_vault/
error.rs

1//! Error types for cryptographic operations
2
3use thiserror::Error;
4
5/// Errors that can occur during cryptographic operations
6#[derive(Error, Debug)]
7pub enum CryptoError {
8    /// Invalid key length
9    #[error("Invalid key length")]
10    InvalidKeyLength,
11
12    /// Encryption failed
13    #[error("Encryption failed: {0}")]
14    EncryptionFailed(String),
15
16    /// Decryption failed
17    #[error("Decryption failed: {0}")]
18    DecryptionFailed(String),
19
20    /// Signature format error
21    #[error("Signature format error: {0}")]
22    SignatureFormatError(String),
23
24    /// Keypair already exists
25    #[error("Keypair already exists: {0}")]
26    KeypairAlreadyExists(String),
27
28    /// Keypair not found
29    #[error("Keypair not found: {0}")]
30    KeypairNotFound(String),
31
32    /// No active key space
33    #[error("No active key space")]
34    NoActiveSpace,
35
36    /// No keypair selected
37    #[error("No keypair selected")]
38    NoKeypairSelected,
39
40    /// Serialization error
41    #[error("Serialization error: {0}")]
42    SerializationError(String),
43
44    /// Invalid address format
45    #[error("Invalid address format: {0}")]
46    InvalidAddress(String),
47
48    /// Smart contract error
49    #[error("Smart contract error: {0}")]
50    ContractError(String),
51}
52
53// Note: Error conversion to main SAL crate will be handled at the integration level