Struct wallet_core::error::Error
source · pub struct Error {
kind: ErrorKind,
details: Option<Box<dyn Error + Send + Sync + 'static>>,
}
Expand description
The error structure, contains details of what may have gone wrong
See the error’s kind for the high level information of what went wrong, it is also possible to then extract details (if any) of the error.
Fields§
§kind: ErrorKind
§details: Option<Box<dyn Error + Send + Sync + 'static>>
Implementations§
source§impl Error
impl Error
sourcepub fn details(&self) -> Option<&(dyn Error + Send + Sync + 'static)>
pub fn details(&self) -> Option<&(dyn Error + Send + Sync + 'static)>
if there are details return the pointer to the error type that triggered the error.
this is useful to display more details as to why an error occurred.
sourcepub fn invalid_input(argument_name: &'static str) -> Self
pub fn invalid_input(argument_name: &'static str) -> Self
construct a Result which is an error with invalid inputs
argument_name
is expected to be a pointer to the parameter name.
example
fn example(pointer: *mut u8) -> Result {
if pointer.is_null() {
Error::invalid_input("pointer")
.with(NulPointer)
.into()
} else {
Result::success()
}
}
let result = example(std::ptr::null_mut());
assert!(result.is_err());
pub fn wallet_recovering() -> Self
pub fn wallet_conversion() -> Self
pub fn wallet_vote_range() -> Self
pub fn wallet_transaction() -> Self
pub fn symmetric_cipher_error(err: Error) -> Self
pub fn invalid_vote_encryption_key() -> Self
pub fn not_enough_funds() -> Self
pub fn invalid_fragment() -> Self
pub fn invalid_transaction_validity_date() -> Self
pub fn invalid_spending_counters() -> Self
sourcepub fn with<E>(self, details: E) -> Selfwhere
E: Error + Send + Sync + 'static,
pub fn with<E>(self, details: E) -> Selfwhere E: Error + Send + Sync + 'static,
set some details to the Result
object if the Result
is of
error kind
If the Result
means success, then nothing is returned.
Example
fn example(pointer: *mut u8) -> Result {
if pointer.is_null() {
Error::invalid_input("pointer").into()
} else {
Result::success()
}
}
let mut input = 2;
let input: *mut u8 = &mut 2;
let result = example(input).with(NulPointer);
assert!(result.is_ok());
Trait Implementations§
source§impl Error for Error
impl Error for Error
source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
The lower-level source of this error, if any. Read more
1.0.0 · source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()
Auto Trait Implementations§
impl !RefUnwindSafe for Error
impl Send for Error
impl Sync for Error
impl Unpin for Error
impl !UnwindSafe for Error
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
Mutably borrows from an owned value. Read more