[][src]Trait exonum::runtime::ExecutionFail

pub trait ExecutionFail {
    fn kind(&self) -> ErrorKind;
fn description(&self) -> String; fn with_description(&self, description: impl Display) -> ExecutionError { ... } }

Trait representing an error type defined in the service or runtime code.

This trait can be derived from an enum using an eponymous derive macro from the exonum-derive crate. Using such errors is the preferred way to generate errors in Rust services.

Examples

use exonum_derive::*;

/// Error codes emitted by wallet transactions during execution:
#[derive(Debug, ExecutionFail)]
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,
}

Required methods

fn kind(&self) -> ErrorKind

Extracts the error kind.

fn description(&self) -> String

Extracts the human-readable error description.

Loading content...

Provided methods

fn with_description(&self, description: impl Display) -> ExecutionError

Creates an error with an externally provided description. The default implementation takes the description as is; implementations can redefine this to wrap it in an error-specific wrapper.

Loading content...

Implementors

impl ExecutionFail for CommonError[src]

impl ExecutionFail for CoreError[src]

Loading content...