feat(interface-types) Add the NegativeValue instruction error.

This commit is contained in:
Ivan Enderlin 2020-03-26 08:31:06 +01:00
parent c35996c233
commit 5275f3f306

View File

@ -149,6 +149,12 @@ pub enum InstructionErrorKind {
/// The string contains invalid UTF-8 encoding.
String(string::FromUtf8Error),
/// A negative value isn't allowed (like a negative pointer value).
NegativeValue {
/// The variable name that triggered the error.
subject: &'static str,
},
}
impl Error for InstructionErrorKind {}
@ -227,6 +233,12 @@ impl Display for InstructionErrorKind {
"{}",
error
),
Self::NegativeValue { subject } => write!(
formatter,
"read the value of `{}` which must be positive",
subject
),
}
}
}