rustywallet_batch/
error.rs

1//! Error types for batch key generation operations.
2//!
3//! This module provides the [`BatchError`] enum which covers all possible
4//! error conditions during batch key generation.
5
6use thiserror::Error;
7
8/// Errors that can occur during batch key generation.
9#[derive(Debug, Error)]
10pub enum BatchError {
11    /// Invalid configuration parameter.
12    #[error("Invalid configuration: {0}")]
13    InvalidConfig(String),
14
15    /// Insufficient system resources (memory, CPU, etc.).
16    #[error("Insufficient system resources: {0}")]
17    ResourceExhausted(String),
18
19    /// Cryptographic operation failed.
20    #[error("Cryptographic operation failed: {0}")]
21    CryptoError(String),
22
23    /// Parallel processing error.
24    #[error("Parallel processing error: {0}")]
25    ParallelError(String),
26
27    /// Key generation failed.
28    #[error("Key generation failed: {0}")]
29    GenerationError(String),
30
31    /// Scanner operation failed.
32    #[error("Scanner operation failed: {0}")]
33    ScannerError(String),
34
35    /// Stream operation failed.
36    #[error("Stream operation failed: {0}")]
37    StreamError(String),
38}
39
40impl BatchError {
41    /// Create a new invalid configuration error.
42    pub fn invalid_config(msg: impl Into<String>) -> Self {
43        Self::InvalidConfig(msg.into())
44    }
45
46    /// Create a new resource exhausted error.
47    pub fn resource_exhausted(msg: impl Into<String>) -> Self {
48        Self::ResourceExhausted(msg.into())
49    }
50
51    /// Create a new cryptographic error.
52    pub fn crypto_error(msg: impl Into<String>) -> Self {
53        Self::CryptoError(msg.into())
54    }
55
56    /// Create a new parallel processing error.
57    pub fn parallel_error(msg: impl Into<String>) -> Self {
58        Self::ParallelError(msg.into())
59    }
60
61    /// Create a new generation error.
62    pub fn generation_error(msg: impl Into<String>) -> Self {
63        Self::GenerationError(msg.into())
64    }
65
66    /// Create a new scanner error.
67    pub fn scanner_error(msg: impl Into<String>) -> Self {
68        Self::ScannerError(msg.into())
69    }
70
71    /// Create a new stream error.
72    pub fn stream_error(msg: impl Into<String>) -> Self {
73        Self::StreamError(msg.into())
74    }
75}