pub enum CniError {
Show 14 variants
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,
},
}Expand description
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.
InvalidEnv
When an environment variable couldn’t be parsed or is invalid.
NoCwd
When the current working directory cannot be obtained (for delegation).
MissingPlugin
When a delegated plugin cannot be found on CNI_PATH.
Delegated
Wrapper for errors in relation to a delegated plugin.
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,
};Implementations§
Source§impl CniError
impl CniError
Sourcepub fn into_reply(self, cni_version: Version) -> ErrorReply<'static>
pub fn into_reply(self, cni_version: Version) -> ErrorReply<'static>
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§
Source§impl Error for CniError
impl Error for CniError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
Auto Trait Implementations§
impl Freeze for CniError
impl !RefUnwindSafe for CniError
impl !Send for CniError
impl !Sync for CniError
impl Unpin for CniError
impl !UnwindSafe for CniError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more