1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
use crate::instruction::InstructionError;
use thiserror::Error;

#[derive(Debug, Error)]
pub enum CaratsError {
    /// arithmetic underflowed
    #[error("Arithmetic underflowed")]
    ArithmeticUnderflow,

    /// arithmetic overflowed
    #[error("Arithmetic overflowed")]
    ArithmeticOverflow,
}

impl From<CaratsError> for InstructionError {
    fn from(error: CaratsError) -> Self {
        match error {
            CaratsError::ArithmeticOverflow => InstructionError::ArithmeticOverflow,
            CaratsError::ArithmeticUnderflow => InstructionError::ArithmeticOverflow,
        }
    }
}