mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-30 07:14:46 +00:00
Avoid panic
This commit is contained in:
parent
a003a16979
commit
70b80c275f
1 changed files with 4 additions and 2 deletions
|
@ -49,7 +49,9 @@ fn init_backtrace_storage() {
|
||||||
|
|
||||||
fn panic_hook(_: &PanicInfo) {
|
fn panic_hook(_: &PanicInfo) {
|
||||||
if let Some(storage) = BACKTRACE.get() {
|
if let Some(storage) = BACKTRACE.get() {
|
||||||
*storage.lock().unwrap() = Some(Backtrace::force_capture().to_string());
|
let _ = storage.lock().map(|ref mut storage| {
|
||||||
|
**storage = Some(Backtrace::force_capture().to_string());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -165,7 +167,7 @@ fn notify_repl_panic(target: Target, e: Box<dyn Any + Send>) -> ReplAction<'stat
|
||||||
|
|
||||||
let backtrace = BACKTRACE
|
let backtrace = BACKTRACE
|
||||||
.get()
|
.get()
|
||||||
.and_then(|storage| storage.lock().unwrap().take())
|
.and_then(|storage| storage.lock().ok().as_deref_mut().and_then(Option::take))
|
||||||
.unwrap_or_else(|| "<Backtrace not found>".to_string());
|
.unwrap_or_else(|| "<Backtrace not found>".to_string());
|
||||||
|
|
||||||
println!(
|
println!(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue