[][src]Struct exonum::runtime::error::ExecutionError

pub struct ExecutionError {
    pub kind: ErrorKind,
    pub description: String,
}

Result of unsuccessful runtime execution.

An execution error consists of an error kind and optional description. The error code affects the blockchain state hash, while the description does not. Therefore descriptions are mostly used for developer purposes, not for interaction of the system with users.

Usually you can implement conversion from your own error type to the ExecutionError via deriving IntoExecutionError from exonum-derive crate.

This macro implements From<MyError> for ExecutionError conversion for the given enum. Enumeration should have an explicit discriminant for each error kind. Derives Display and Fail traits using documentation comments for each error kind.

Examples

Deriving errors in service transactions:

use exonum_derive::IntoExecutionError;

/// Error codes emitted by wallet transactions during execution:
#[derive(Debug, IntoExecutionError)]
pub enum Error {
    /// Content hash already exists.
    HashAlreadyExists = 0,
    /// Unable to parse the service configuration.
    ConfigParseError = 1,
    /// Time service with the specified name does not exist.
    TimeServiceNotFound = 2,
}

Deriving errors in runtimes:

use exonum_derive::IntoExecutionError;

// Define runtime specific errors.
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd, IntoExecutionError)]
#[execution_error(kind = "runtime")]
enum SampleRuntimeError {
    /// Incorrect information to call the transaction.
    IncorrectCallInfo = 1,
    /// Incorrect transaction payload.
    IncorrectPayload = 2,
}

Fields

kind: ErrorKind

The kind of error that indicates in which module and with which code the error occurred.

description: String

Optional description which doesn't affect object_hash.

Methods

impl ExecutionError[src]

pub fn new(kind: ErrorKind, description: impl Into<String>) -> Self[src]

Creates a new execution error instance with the specified error kind and an optional description.

Trait Implementations

impl From<Error> for ExecutionError[src]

impl<E, T> From<(E, T)> for ExecutionError where
    T: Display,
    E: Into<ErrorKind>, 
[src]

impl From<Error> for ExecutionError[src]

impl Clone for ExecutionError[src]

impl Eq for ExecutionError[src]

impl Ord for ExecutionError[src]

impl PartialEq<ExecutionError> for ExecutionError[src]

impl PartialOrd<ExecutionError> for ExecutionError[src]

impl Debug for ExecutionError[src]

impl Display for ExecutionError[src]

impl Hash for ExecutionError[src]

impl StructuralPartialEq for ExecutionError[src]

impl StructuralEq for ExecutionError[src]

impl Fail for ExecutionError[src]

impl BinaryValue for ExecutionError[src]

impl ObjectHash for ExecutionError[src]

impl ProtobufConvert for ExecutionError[src]

type ProtoStruct = ExecutionError

Type of the protobuf clone of Self

Auto Trait Implementations

Blanket Implementations

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

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

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

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

type Error = !

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<T> Borrow<T> for T where
    T: ?Sized
[src]

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

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

impl<T> AsFail for T where
    T: Fail
[src]

impl<E> Fail for E where
    E: 'static + Error + Send + Sync
[src]

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

impl<T> Erased for T

impl<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]