* add/sub lamports * make add/sub return Result * sample replacements * cleanup * fix up a few tests as examples * move enum, cleanup, impl from * fmt * cleanup * add lamports.rs
23 lines
612 B
Rust
23 lines
612 B
Rust
use crate::instruction::InstructionError;
|
|
use thiserror::Error;
|
|
|
|
#[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,
|
|
}
|
|
}
|
|
}
|