1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
//! Crate error types

use thiserror::Error;

/// Error type for all errors in this crate
#[derive(Error, Debug, Eq, PartialEq)]
pub enum Chip8Error {
    /// Invalid register definition
    #[error("invalid register {0:?}")]
    InvalidRegister(u8),

    /// Unknown instruction
    #[error("unknown instruction {0:?}")]
    UnknownInstruction(u16),

    /// Known but unimplemented instruction
    #[error("unimplemented instruction {0:?}")]
    UnimplementedInstruction(crate::instructions::Instruction),

    /// Invalid key definition
    #[error("invalid key {0:?}")]
    InvalidKey(u8),
}

/// Result alias
pub type Result<T> = std::result::Result<T, Chip8Error>;