[][src]Struct exonum::runtime::ErrorMatch

pub struct ErrorMatch { /* fields omitted */ }

Matcher for ExecutionErrors that can have some fields unspecified. Can be compared to an ExceptionError, e.g., in tests. The unspecified fields will match any value in the error.

Examples

use exonum::runtime::{ExecutionError, InstanceId, ErrorMatch};
use exonum_derive::ExecutionFail;

#[derive(Debug, ExecutionFail)]
pub enum Error {
    /// Content hash already exists.
    HashAlreadyExists = 0,
    // other variants...
}

// Identifier of the service that will cause an error.
const SERVICE_ID: InstanceId = 100;

let err: &ExecutionError = // ...
let matcher = ErrorMatch::from_fail(&Error::HashAlreadyExists)
    .for_service(SERVICE_ID);
assert_eq!(*err, matcher);

Methods

impl ErrorMatch[src]

pub fn from_fail<F: ExecutionFail + ?Sized>(fail: &F) -> Self[src]

Creates a matcher from the provided error.

The converted error has a kind and description set to the values returned by the corresponding methods of the ExecutionFail trait. The call site information (e.g., the instance ID) is not set.

pub fn any_unexpected() -> Self[src]

Creates a matcher for Unexpected kind of errors. By default it will match any description.

pub fn with_any_description(self) -> Self[src]

Accepts an error with any description.

pub fn with_description_containing(self, pat: impl Into<String>) -> Self[src]

Accepts an error with any description containing the specified string.

pub fn with_description_matching<P>(self, pat: P) -> Self where
    P: Fn(&str) -> bool + 'static, 
[src]

Accepts an error with any description matching the specified closure.

pub fn in_runtime(self, runtime_id: u32) -> Self[src]

Accepts an error that has occurred in a runtime with the specified ID.

pub fn for_service(self, instance_id: InstanceId) -> Self[src]

Accepts an error that has occurred in a service with the specified ID.

pub fn in_call(self, call_type: CallType) -> Self[src]

Accepts an error that has occurred in a call of the specified format.

Trait Implementations

impl Debug for ErrorMatch[src]

impl PartialEq<ErrorMatch> for ExecutionError[src]

impl PartialEq<ExecutionError> for ErrorMatch[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,