pub enum SignerError {
InvalidPassphrase(String),
InvalidAddress,
BuilderError(BuilderError),
WalletError(WalletError),
CryptoError(CryptoError),
RustcFromHexError(FromHexError),
TypeError(TypeError),
}
Expand description
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 viarustc_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),
},
}
}
Variants§
InvalidPassphrase(String)
Represents an error when an invalid passphrase is provided. This could happen during the decryption of a private key or any operation that requires passphrase verification.
InvalidAddress
Indicates that the provided address is not valid. This error might occur if an address does not comply with expected formats or checksums.
BuilderError(BuilderError)
Wraps errors related to building or configuring objects, possibly during the setup of cryptographic operations or when constructing complex objects that have specific requirements.
WalletError(WalletError)
Encapsulates errors that originate from wallet operations. This can include issues with creating, loading, or performing transactions with wallets.
CryptoError(CryptoError)
Covers general cryptographic errors such as failures in hashing, signature generation, or encryption/decryption processes.
RustcFromHexError(FromHexError)
An error for hex decoding issues.
TypeError(TypeError)
Indicates a failure related to type conversion or coercion. This variant is useful for signaling issues when trying to convert between incompatible types, such as when deserializing data into a specific structure.
Trait Implementations§
Source§impl Debug for SignerError
impl Debug for SignerError
Source§impl Display for SignerError
impl Display for SignerError
Source§impl Error for SignerError
impl Error for SignerError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
Source§impl From<BuilderError> for SignerError
impl From<BuilderError> for SignerError
Source§fn from(source: BuilderError) -> Self
fn from(source: BuilderError) -> Self
Source§impl From<CryptoError> for SignerError
impl From<CryptoError> for SignerError
Source§fn from(source: CryptoError) -> Self
fn from(source: CryptoError) -> Self
Source§impl From<FromHexError> for SignerError
impl From<FromHexError> for SignerError
Source§fn from(source: FromHexError) -> Self
fn from(source: FromHexError) -> Self
Source§impl From<TypeError> for SignerError
impl From<TypeError> for SignerError
Source§impl From<WalletError> for SignerError
impl From<WalletError> for SignerError
Source§fn from(source: WalletError) -> Self
fn from(source: WalletError) -> Self
Auto Trait Implementations§
impl Freeze for SignerError
impl !RefUnwindSafe for SignerError
impl Send for SignerError
impl Sync for SignerError
impl Unpin for SignerError
impl !UnwindSafe for SignerError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string
, but without panic on OOM.