2022-04-20 18:20:17 -07:00
|
|
|
//! Defines the [`LamportsError`] type.
|
|
|
|
|
2021-12-03 09:00:31 -08:00
|
|
|
use {crate::instruction::InstructionError, thiserror::Error};
|
2021-04-23 13:20:48 -07:00
|
|
|
|
|
|
|
#[derive(Debug, Error)]
|
|
|
|
pub enum LamportsError {
|
|
|
|
/// arithmetic underflowed
|
|
|
|
#[error("Arithmetic underflowed")]
|
|
|
|
ArithmeticUnderflow,
|
|
|
|
|
|
|
|
/// arithmetic overflowed
|
|
|
|
#[error("Arithmetic overflowed")]
|
|
|
|
ArithmeticOverflow,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl From<LamportsError> for InstructionError {
|
|
|
|
fn from(error: LamportsError) -> Self {
|
|
|
|
match error {
|
|
|
|
LamportsError::ArithmeticOverflow => InstructionError::ArithmeticOverflow,
|
|
|
|
LamportsError::ArithmeticUnderflow => InstructionError::ArithmeticOverflow,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|