Browse Source

Implement proper panic messages

pull/10/head
Fenrir 9 years ago
parent
commit
189fa64b3f
  1. 8
      src/lib.rs
  2. 22
      src/panic.rs

8
src/lib.rs

@ -11,14 +11,8 @@ pub mod gfx;
pub mod sdmc; pub mod sdmc;
pub mod services; pub mod services;
pub mod panic;
pub use srv::Srv; pub use srv::Srv;
pub use gfx::Gfx; pub use gfx::Gfx;
pub use sdmc::Sdmc; pub use sdmc::Sdmc;
#[lang = "eh_personality"]
extern "C" fn eh_personality() {}
#[lang = "panic_fmt"]
fn panic_fmt() -> ! {
unsafe { libctru::libc::abort() }
}

22
src/panic.rs

@ -0,0 +1,22 @@
use core::fmt::{Arguments, Write};
#[lang = "eh_personality"]
extern "C" fn eh_personality() {}
#[lang = "panic_fmt"]
extern fn panic_fmt(fmt: Arguments, file: &str, line: u32) -> ! {
use gfx::Screen;
use console::Console;
let mut error_top = Console::init(Screen::Top);
let mut error_bottom = Console::init(Screen::Bottom);
writeln!(error_top, "--------------------------------------------------").unwrap();
writeln!(error_top, "PANIC in {} at line {}:", file, line).unwrap();
writeln!(error_top, " {}", fmt).unwrap();
write!(error_top, "\x1b[29;00H--------------------------------------------------").unwrap();
writeln!(error_bottom, "").unwrap();
loop {}
}
Loading…
Cancel
Save