mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-16 08:38:26 +00:00
make screen panic messages somewhat more useful
some panic messages are hundreds of characters long, most of them are path hashes or paths to crates that are less useful. truncate any panic messages to the last set of displayable characters, so that the "most useful" portion (e.g. file name and line number) are always visible in a panic.
This commit is contained in:
parent
106f7153a1
commit
3b1784d346
1 changed files with 11 additions and 1 deletions
|
|
@ -124,7 +124,17 @@ pub(crate) fn panic_handler_thread(
|
|||
}
|
||||
.get();
|
||||
let s = unsafe { core::str::from_utf8_unchecked(&body.buf.as_slice()[..len]) };
|
||||
append_string(s, &mut display);
|
||||
const MAX_CHARS: usize = 7 * 18; // 7 lines by 18 characters is what the display can hold
|
||||
if s.chars().count() <= MAX_CHARS {
|
||||
append_string(s, &mut display);
|
||||
} else {
|
||||
// truncate very long panic messages to just show the *end* as that contains the useful
|
||||
// information (the front tends to be stuff like path information in the build)
|
||||
append_string(
|
||||
s.char_indices().rev().take(MAX_CHARS).last().map(|(i, _)| &s[i..]).unwrap(),
|
||||
&mut display,
|
||||
);
|
||||
}
|
||||
display.draw();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue