error message rather than panic

This commit is contained in:
Alex Janka 2023-02-09 11:57:51 +11:00
parent 09b1cb1e57
commit ad8d001f0c

View file

@ -108,8 +108,20 @@ fn main() {
*v = args.verbose;
}
let rom: ROM = ROM::load(fs::read(args.rom).expect("Could not load ROM"));
let bootrom: Vec<u8> = fs::read(args.bootrom).expect("Could not load BootROM");
let rom: ROM = match fs::read(args.rom) {
Ok(data) => ROM::load(data),
Err(e) => {
println!("Error reading ROM: {}", e.to_string());
return;
}
};
let bootrom: Vec<u8> = match fs::read(args.bootrom) {
Ok(data) => data,
Err(e) => {
println!("Error reading bootROM: {}", e.to_string());
return;
}
};
let mut window = Window::new(
format!("{}", rom.get_title()).as_str(),