Error: Remove FunkyMathError and Stringly Typed context

This commit is contained in:
2023-03-29 23:42:41 -05:00
parent 9195d439e3
commit c194a3c53a
3 changed files with 12 additions and 13 deletions

View File

@@ -5,7 +5,7 @@
//!
//! This is more of a memory management unit + some utils for reading/writing
use crate::error::Result;
use crate::error::{Error::MissingRegion, Result};
use std::{
fmt::{Debug, Display, Formatter},
ops::Range,
@@ -319,9 +319,7 @@ impl Bus {
}
}
} else {
return Err(crate::error::Error::MissingRegion {
region: REGION.to_string(),
});
return Err(MissingRegion { region: REGION });
}
Ok(())
}

View File

@@ -3,6 +3,7 @@
//! Error type for Chirp
use crate::bus::Region;
use thiserror::Error;
pub type Result<T> = std::result::Result<T, Error>;
@@ -10,13 +11,15 @@ pub type Result<T> = std::result::Result<T, Error>;
#[derive(Debug, Error)]
pub enum Error {
#[error("Unrecognized opcode {word}")]
UnimplementedInstruction { word: u16 },
#[error("Math was funky when parsing {word}: {explanation}")]
FunkyMath { word: u16, explanation: String },
UnimplementedInstruction {
word: u16,
},
#[error("No {region} found on bus")]
MissingRegion { region: String },
MissingRegion {
region: Region,
},
#[error(transparent)]
IoError(#[from] std::io::Error),
#[error(transparent)]
WindowError(#[from] minifb::Error),
MinifbError(#[from] minifb::Error),
}