Skip to content
This repository has been archived by the owner on May 23, 2024. It is now read-only.

Commit

Permalink
lib: Pretty-print PanicInfo (#5)
Browse files Browse the repository at this point in the history
* lib: Pretty-print `PanicInfo`

instead of relying solely on the `Debug` trait for printing. Also add
some more space to the output, so the Panic is easily recognized between
application text and the backtrace.

* lib: Use debug struct printing for panic
  • Loading branch information
har7an authored Aug 19, 2022
1 parent 3c1b5f6 commit a795863
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,21 @@ pub mod arch;
fn panic_handler(info: &core::panic::PanicInfo) -> ! {
use esp_println::*;

println!("{:?}", info);
println!(" ");
println!(" ");

if let Some(location) = info.location() {
let (file, line, column) = (location.file(), location.line(), location.column());
println!("!! A panic occured in '{file}', at line {line}, column {column}");
} else {
println!("!! A panic occured at an unknown location");
}

println!(" ");
println!("{:#?}", info);
println!(" ");
println!("Backtrace:");
println!(" ");

let backtrace = crate::arch::backtrace();
for e in backtrace {
Expand Down

0 comments on commit a795863

Please sign in to comment.