Enum cni_plugin::error::CniError[][src]

pub enum CniError {
    Io(Error),
    Json(Error),
    Incompatible(Version),
    MissingInput,
    MissingOutput,
    MissingEnv {
        var: &'static str,
        err: VarError,
    },
    InvalidEnv {
        var: &'static str,
        err: Box<dyn Error>,
    },
    NoCwd,
    MissingPlugin {
        name: String,
        err: Error,
    },
    Delegated {
        plugin: String,
        err: Box<Self>,
    },
    Generic(String),
    Debug(Box<dyn Debug>),
    MissingField(&'static str),
    InvalidField {
        field: &'static str,
        expected: &'static str,
        value: Value,
    },
}

All errors emitted by this library, plus a few others.

Variants

Io(Error)

Catch-all wrapper for I/O errors.

Json(Error)

Catch-all wrapper for JSON serialization and deserialization.

Incompatible(Version)

When the CNI version requested by the runtime is not supported.

The Version in the error is the CNI version provided, not ours.

Also see VersionReply.

MissingInput

When nothing is provided on STDIN.

MissingOutput

When a delegated plugin doesn’t output anything on STDOUT.

MissingEnv

When a required environment variable is missing.

Fields of MissingEnv

var: &'static str

the variable name

err: VarError

the underlying error

InvalidEnv

When an environment variable couldn’t be parsed or is invalid.

Fields of InvalidEnv

var: &'static str

the variable name

err: Box<dyn Error>

the underlying error

NoCwd

When the current working directory cannot be obtained (for delegation).

MissingPlugin

When a delegated plugin cannot be found on CNI_PATH.

Fields of MissingPlugin

name: String

the name of the plugin binary

err: Error

the underlying error

Delegated

Wrapper for errors in relation to a delegated plugin.

Fields of Delegated

plugin: String

the name of the plugin binary

err: Box<Self>

the underlying error

Generic(String)

A generic error as a string.

This error variant is not used in the library, but is provided for plugin implementations to make use of without needing to make their own error type.

Example

CniError::Generic("a total catastrophe".into());
Debug(Box<dyn Debug>)

A debug error as anything that implements Debug.

This error variant is not used in the library, but is provided for plugin implementations to make use of without needing to make their own error type.

Example

CniError::Debug(Box::new(("hello", "world", vec![1, 2, 3])));
MissingField(&'static str)

When a field in configuration is missing.

This error variant is not used in the library, but is provided for plugin implementations to make use of without needing to make their own error type.

Example

CniError::MissingField("ipam.type");
InvalidField

When a field in configuration is invalid.

This error variant is not used in the library, but is provided for plugin implementations to make use of without needing to make their own error type.

Example

CniError::InvalidField {
    field: "ipam.pool",
    expected: "string",
    value: Value::Null,
};

Fields of InvalidField

field: &'static str

the name or path of the invalid field

expected: &'static str

the value or type the field was expected to be

value: Value

the actual value or a facsimile thereof

Implementations

impl CniError[src]

pub fn into_reply(self, cni_version: Version) -> ErrorReply<'static>[src]

Convert a CniError into an ErrorReply.

ErrorReplys can be used with reply, but require cni_version to be set to the input configuration’s. This method makes it easier to create errors (including with the ? operator, from foreign error types) and only populate the version field when ready to send the reply.

It’s recommended to add an implementation of this if you make your own error type.

Trait Implementations

impl Debug for CniError[src]

impl Display for CniError[src]

impl Error for CniError[src]

impl From<Error> for CniError[src]

impl From<Error> for CniError[src]

Auto Trait Implementations

impl !RefUnwindSafe for CniError

impl !Send for CniError

impl !Sync for CniError

impl Unpin for CniError

impl !UnwindSafe for CniError

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> ToString for T where
    T: Display + ?Sized
[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.