1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
use crate::;
use Error;
/// Represents errors that can occur within the signing process.
///
/// This enum encapsulates a variety of errors that may arise when performing
/// operations related to signing transactions, messages, or performing cryptographic
/// operations within a blockchain context. It includes errors related to invalid input
/// data (like passphrases or addresses), failures in underlying cryptographic operations,
/// and errors from external libraries used for tasks such as hex encoding/decoding or
/// type conversion.
///
/// Variants of this enum are designed to be converted from errors thrown by these
/// operations, allowing for a unified error handling interface throughout the signing
/// process.
///
/// # Variants
///
/// - `InvalidPassphrase`: Occurs when a passphrase does not meet validation criteria.
/// - `InvalidAddress`: Triggered by malformed blockchain addresses.
/// - `BuilderError`: Wraps errors from the construction of cryptographic objects.
/// - `WalletError`: Encompasses errors from wallet operations.
/// - `FromHexError`: Pertains to failures in hexadecimal to binary data conversion.
/// - `CryptoError`: Covers general cryptographic failures.
/// - `RustcFromHexError`: Specific to hex decoding issues via `rustc_serialize`.
/// - `TypeError`: Indicates failures in type conversion or coercion.
///
/// # Examples
///
/// Handling a `SignerError` in a function that performs signing operations might look
/// like this:
///
/// ```
/// use neo3::prelude::*;
/// async fn sign_data(data: &[u8]) -> Result<(), wallets::SignerError> {
/// // Example function body
/// Ok(())
/// }
///
/// async fn example_usage() {
/// let data = b"example data";
///
/// match sign_data(data).await {
/// Ok(_) => println!("Data signed successfully"),
/// Err(e) => match e {
/// wallets::SignerError::InvalidPassphrase(_) => println!("Invalid passphrase provided"),
/// wallets::SignerError::InvalidAddress => println!("Invalid address"),
/// // Handle other errors accordingly
/// _ => println!("An error occurred: {:?}", e),
/// },
/// }
/// }
/// ```