Macro execution_error

Source
execution_error!() { /* proc-macro */ }
Expand description

Implements Into<odra::types::ExecutionError> and Into<odra::types::OdraError> for an error enum.

An enum should use a custom syntax, and each variant is mapped to n error code e.g. Name => 1.

§Examples

use odra;

odra::execution_error! {
    pub enum Error {
        Fatal => 1,
        Checked => 2,
    }
};

let exec_error: odra::types::ExecutionError = Error::Fatal.into();
let odra_error: odra::types::OdraError = Error::Checked.into();

Each variant must have a code.

use odra;

odra::execution_error! {
    pub enum Error {
        Fatal => 1,
        Checked,
    }
};

Each code must be unique.

use odra;

odra::execution_error! {
    pub enum Error {
        Fatal => 1,
        Checked => 1,
    }
};