diff options
| author | Fenrir <[email protected]> | 2016-08-05 02:23:52 -0700 |
|---|---|---|
| committer | Fenrir <[email protected]> | 2016-08-05 02:25:23 -0700 |
| commit | 189fa64b3f1daf21ce2909edb61bff935223eaaf (patch) | |
| tree | 50ac69bc030afb7c55907cf69e6ce322f9ae5ef5 /src | |
| parent | Rename ::new() to ::init() (diff) | |
| download | ctru-rs-189fa64b3f1daf21ce2909edb61bff935223eaaf.tar.xz ctru-rs-189fa64b3f1daf21ce2909edb61bff935223eaaf.zip | |
Implement proper panic messages
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib.rs | 8 | ||||
| -rw-r--r-- | src/panic.rs | 22 |
2 files changed, 23 insertions, 7 deletions
@@ -11,14 +11,8 @@ pub mod gfx; pub mod sdmc; pub mod services; +pub mod panic; pub use srv::Srv; pub use gfx::Gfx; pub use sdmc::Sdmc; - -#[lang = "eh_personality"] -extern "C" fn eh_personality() {} -#[lang = "panic_fmt"] -fn panic_fmt() -> ! { - unsafe { libctru::libc::abort() } -} diff --git a/src/panic.rs b/src/panic.rs new file mode 100644 index 0000000..c0e4d0a --- /dev/null +++ b/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 {} +} |