Error: Remove FunkyMathError and Stringly Typed context
This commit is contained in:
		| @@ -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(()) | ||||
|     } | ||||
|   | ||||
							
								
								
									
										13
									
								
								src/error.rs
									
									
									
									
									
								
							
							
						
						
									
										13
									
								
								src/error.rs
									
									
									
									
									
								
							| @@ -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), | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user