Enum to Encapulate Errors


Creating a enum to encapsulate Errors.

/// Error message when unable to construct a new Mechanism.
#[derive(Debug, PartialEq)]
pub enum MechanismError {
    /// Indicates that the provided string is not correctly formed.
    NotValidMechanismFormat(String),
    /// Indcates that the provided string could not be parsed into an IpNetwork::IP4 though it is a valid IpNetwork.
    NotIP4Network(String),
    /// Indcates that the provided string could not be parsed into an IpNetwork::IP6 though it is a valid IpNetwork.
    NotIP6Network(String),
    /// Indicates that the provided string does not contain any valid IpNetwork.
    NotValidIPNetwork(String),
    /// Attempted to access a Mechanism as a `Mechanism<IpNetwork>` but is `Mechanism<String>`
    NotIpNetworkMechanism,
    /// Attempted to access a Mechanism as a `Mechanism<String>` but is `Mechanism<IpNetwork>`
    NotStringMechanism,
}

impl std::error::Error for MechanismError {}

Reference:

Rust: Enums to wrap multiple errors


See also