Fix handling of panics
diff --git a/src/lang_items.rs b/src/lang_items.rs index 9733015..b8731a2 100644 --- a/src/lang_items.rs +++ b/src/lang_items.rs
@@ -31,7 +31,7 @@ where T: Termination, { - main(); + main().check_result(); } #[lang = "termination"] @@ -45,12 +45,18 @@ impl Termination for TockResult<()> { fn check_result(self) { - self.ok().unwrap() + if self.is_err() { + unsafe { report_panic() }; + } } } #[panic_handler] unsafe fn panic_handler(_info: &PanicInfo) -> ! { + report_panic() +} + +unsafe fn report_panic() -> ! { // Signal a panic using the LowLevelDebug capsule (if available). super::debug::low_level_status_code(1);