68 lines
1.3 KiB
Rust
68 lines
1.3 KiB
Rust
#[derive(Debug)]
|
|
pub enum GeorgeErrorKind {
|
|
Memory(MemoryError),
|
|
Execution(ExecutionError),
|
|
AddrMode(AddressingModeError),
|
|
Mapping(MappingError),
|
|
}
|
|
|
|
impl From<MemoryError> for GeorgeErrorKind {
|
|
fn from(value: MemoryError) -> Self {
|
|
Self::Memory(value)
|
|
}
|
|
}
|
|
impl From<AddressingModeError> for GeorgeErrorKind {
|
|
fn from(value: AddressingModeError) -> Self {
|
|
Self::AddrMode(value)
|
|
}
|
|
}
|
|
impl From<ExecutionError> 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<ExecutionError> for AddressingModeError {
|
|
fn from(_value: ExecutionError) -> Self {
|
|
Self::IncompatibleAddrMode
|
|
}
|
|
}
|
|
|
|
impl From<MemoryError> 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,
|
|
}
|