add: more helpful warning msgs

This commit is contained in:
2025-02-20 08:10:40 +00:00
parent 867774e367
commit 9eea36efa5
3 changed files with 17 additions and 3 deletions

View File

@@ -3,7 +3,6 @@ use crate::device::keyboard::Keyboard;
use crate::device::timer::DeviceTimerManager;
use crate::util::{DeviceConfig, EmulatorResult};
use rand::random;
use rand::seq::IteratorRandom;
use std::sync::{Arc, Mutex};
use std::thread::sleep;
use std::time::Duration;

View File

@@ -2,7 +2,6 @@ use std::sync::{Arc, Mutex};
use std::sync::mpsc::Sender;
use std::thread;
use std::thread::JoinHandle;
use std::time::Duration;
use clap::Parser;
use log::LevelFilter;
use sdl2::audio::{AudioQueue, AudioSpecDesired};
@@ -66,7 +65,7 @@ fn main() -> EmulatorResult<()> {
match event {
Event::Quit { .. } |
Event::KeyDown { keycode: Some(Keycode::Escape), .. } => {
device_termination_signal_sender.send(()).expect("Could not send");
device_termination_signal_sender.send(())?;
break 'running;
}
Event::KeyDown { keycode: Some(keycode), repeat: false, .. } => {

View File

@@ -1,6 +1,7 @@
use crate::device::keyboard::KeyboardEvent;
use sdl2::video::WindowBuildError;
use sdl2::IntegerOrSdlError;
use std::fmt::Display;
use std::sync::mpsc::SendError;
use std::sync::PoisonError;
use std::time::Duration;
@@ -51,6 +52,21 @@ pub enum EmulatorError {
MutexInvalidState(String),
}
impl Display for EmulatorError{
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self{
EmulatorError::SdlError(err) => write!(f,"Error with SDL: {}",err),
EmulatorError::IOError(io_err) => write!(f,"IO Error: {}",io_err),
EmulatorError::MutexInvalidState(invalid_mutex_err) => write!(f,"Issue from mutex: {}",invalid_mutex_err),
}
}
}
impl From<SendError<()>> for EmulatorError{
fn from(value: SendError<()>) -> Self {
Self::IOError(String::from("Could not update as: ")+value.to_string().as_str())
}
}
impl From<String> for EmulatorError {
fn from(value: String) -> Self {
Self::SdlError(value)