[err] Error names

This commit is contained in:
2024-02-17 11:22:26 +05:30
parent 1aecdacfde
commit 562a33cdc2
4 changed files with 9 additions and 9 deletions

View File

@@ -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(())