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    /// I/O operation failed.
40    #[error("I/O error: {0}")]
41    IoError(String),
42}
43
44impl BatchError {
45    /// Create a new invalid configuration error.
46    pub fn invalid_config(msg: impl Into<String>) -> Self {
47        Self::InvalidConfig(msg.into())
48    }
49
50    /// Create a new resource exhausted error.
51    pub fn resource_exhausted(msg: impl Into<String>) -> Self {
52        Self::ResourceExhausted(msg.into())
53    }
54
55    /// Create a new cryptographic error.
56    pub fn crypto_error(msg: impl Into<String>) -> Self {
57        Self::CryptoError(msg.into())
58    }
59
60    /// Create a new parallel processing error.
61    pub fn parallel_error(msg: impl Into<String>) -> Self {
62        Self::ParallelError(msg.into())
63    }
64
65    /// Create a new generation error.
66    pub fn generation_error(msg: impl Into<String>) -> Self {
67        Self::GenerationError(msg.into())
68    }
69
70    /// Create a new scanner error.
71    pub fn scanner_error(msg: impl Into<String>) -> Self {
72        Self::ScannerError(msg.into())
73    }
74
75    /// Create a new stream error.
76    pub fn stream_error(msg: impl Into<String>) -> Self {
77        Self::StreamError(msg.into())
78    }
79
80    /// Create a new I/O error.
81    pub fn io_error(msg: impl Into<String>) -> Self {
82        Self::IoError(msg.into())
83    }
84}