moa/src/error.rs
2021-10-14 21:16:31 -07:00

47 lines
769 B
Rust

#[derive(Debug)]
pub enum ErrorType {
Emulator,
Processor,
}
#[derive(Debug)]
pub struct Error {
pub err: ErrorType,
pub native: u32,
pub msg: String,
}
impl Error {
pub fn new(msg: &str) -> Error {
Error {
err: ErrorType::Emulator,
native: 0,
msg: msg.to_string(),
}
}
pub fn processor(native: u32) -> Error {
Error {
err: ErrorType::Processor,
native,
msg: "".to_string(),
}
}
}
static mut DEBUG_ENABLE: bool = true;
pub fn debug_enabled() -> bool {
unsafe { DEBUG_ENABLE }
}
macro_rules! debug {
($($arg:tt)*) => ({
if crate::error::debug_enabled() {
println!($($arg)*);
}
})
}