[err] Error names
This commit is contained in:
@@ -15,7 +15,7 @@ impl RamMemory {
|
||||
pub fn try_new() -> EmulatorResult<RamMemory> {
|
||||
let alloc_result = vec![0; MEM_LENGTH].into_boxed_slice();
|
||||
let data = alloc_result.try_into().map_err(|err|{
|
||||
EmulatorError::AllocationError(RAM,"Allocation failed")
|
||||
EmulatorError::AllocationFailure(RAM, "Allocation failed")
|
||||
})?;
|
||||
Ok(RamMemory {
|
||||
data
|
||||
@@ -27,13 +27,13 @@ impl RamMemory {
|
||||
impl Memory for RamMemory {
|
||||
fn try_get_byte(&self, address: u32) -> EmulatorResult<u8> {
|
||||
log::trace!("Fetch RAM memory at address {}",address);
|
||||
let x = *self.data.get(address as usize).ok_or(EmulatorError::UnreachableMemoryError(RAM,address))?;
|
||||
let x = *self.data.get(address as usize).ok_or(EmulatorError::UnreachableMemory(RAM, address))?;
|
||||
Ok(x)
|
||||
}
|
||||
|
||||
fn try_set_byte(&mut self, address: u32, value: u8) -> EmulatorResult<()> {
|
||||
if address>= MEM_LENGTH as u32 {
|
||||
return Err(EmulatorError::UnreachableMemoryError(RAM,address))
|
||||
return Err(EmulatorError::UnreachableMemory(RAM, address))
|
||||
}
|
||||
self.data[address as usize] = value;
|
||||
Ok(())
|
||||
|
@@ -2,7 +2,7 @@ use crate::emu::iomem::MemoryMappedIO;
|
||||
use crate::emu::mem::RamMemory;
|
||||
use crate::misc::emulator_error::DeviceType::MMU;
|
||||
|
||||
use crate::misc::emulator_error::EmulatorError::UnreachableMemoryError;
|
||||
use crate::misc::emulator_error::EmulatorError::UnreachableMemory;
|
||||
use crate::misc::result::EmulatorResult;
|
||||
|
||||
// 8 bytes that are memory mapped i/o
|
||||
@@ -44,7 +44,7 @@ impl Memory for MappedMemory {
|
||||
RAM_MEM_START..=RAM_MEM_END => {
|
||||
self.ram_memory.try_get_byte(address)
|
||||
}
|
||||
_ => { Err(UnreachableMemoryError(MMU, address)) }
|
||||
_ => { Err(UnreachableMemory(MMU, address)) }
|
||||
}?;
|
||||
|
||||
Ok(byte_at_addr)
|
||||
|
@@ -19,7 +19,7 @@ impl Color {
|
||||
}
|
||||
pub fn try_new(in_mem_color: u8) -> EmulatorResult<Color> {
|
||||
if in_mem_color > Self::COLOR_MAX {
|
||||
return Err(EmulatorError::InvalidColorError(in_mem_color))
|
||||
return Err(EmulatorError::InvalidColor(in_mem_color))
|
||||
}
|
||||
Ok(Color(in_mem_color))
|
||||
}
|
||||
|
@@ -11,9 +11,9 @@ pub enum DeviceType {
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum EmulatorError {
|
||||
AllocationError(DeviceType, &'static str),
|
||||
UnreachableMemoryError(DeviceType, u32),
|
||||
InvalidColorError(u8)
|
||||
AllocationFailure(DeviceType, &'static str),
|
||||
UnreachableMemory(DeviceType, u32),
|
||||
InvalidColor(u8)
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user