#[derive(Debug)] pub enum GeorgeErrorKind { Memory(MemoryError), Execution(ExecutionError), AddrMode(AddressingModeError), Mapping(MappingError), } impl From for GeorgeErrorKind { fn from(value: MemoryError) -> Self { Self::Memory(value) } } impl From for GeorgeErrorKind { fn from(value: AddressingModeError) -> Self { Self::AddrMode(value) } } impl From for GeorgeErrorKind { fn from(value: ExecutionError) -> Self { Self::Execution(value) } } #[derive(Debug)] pub enum ExecutionError { InvalidInstruction, InterruptsDisabled, StackOverflow, MemoryError(MemoryError), } #[derive(Debug)] pub enum AddressingModeError { IncompatibleAddrMode, } impl From for AddressingModeError { fn from(_value: ExecutionError) -> Self { Self::IncompatibleAddrMode } } impl From for ExecutionError { fn from(error: MemoryError) -> Self { ExecutionError::MemoryError(error) } } #[derive(Debug)] pub struct GeorgeError { pub desc: String, pub kind: GeorgeErrorKind, } #[derive(Debug)] pub enum MemoryError { Unmapped, NoDataAtAddress, Unwritable, } #[derive(Debug)] pub enum MappingError { RegionOccupied, InvalidPage, }