-
-
Notifications
You must be signed in to change notification settings - Fork 579
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: do not convert panics to results (#4848)
* feat: do not convert panics to results * feat: add panic handler (#4849)
- Loading branch information
Showing
10 changed files
with
100 additions
and
66 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
use color_backtrace::{default_output_stream, BacktracePrinter}; | ||
|
||
pub fn install_panic_handler() { | ||
BacktracePrinter::default() | ||
.message("Panic occurred at runtime. Please file an issue on GitHub with the backtrace below: https://github.com/web-infra-dev/rspack/issues") | ||
.add_frame_filter(Box::new(|frames| { | ||
static NAME_PREFIXES: &[&str] = &[ | ||
"rust_panic", | ||
"rayon", | ||
"rust_begin_unwind", | ||
"start_thread", | ||
"__clone", | ||
"call_once", | ||
"catch_unwind", | ||
"tokio", | ||
"<tokio::runtime", | ||
"future", | ||
"std::panic", | ||
"<core::panic", | ||
"___rust_try", | ||
]; | ||
static FILE_PREFIXES: &[&str] = &[ | ||
"/rustc/", | ||
"src/libstd/", | ||
"src/libpanic_unwind/", | ||
"src/libtest/", | ||
]; | ||
frames.retain(|x| { | ||
if x.is_post_panic_code() || x.is_runtime_init_code() { | ||
return false; | ||
} | ||
|
||
if matches!(&x.filename, Some(f) if FILE_PREFIXES.iter().any(|l| { | ||
f.starts_with(l) | ||
})) { | ||
return false; | ||
} | ||
|
||
if matches!(&x.name, Some(n) if NAME_PREFIXES.iter().any(|l| { | ||
n.starts_with(l) | ||
})) { | ||
return false; | ||
} | ||
|
||
true | ||
}); | ||
})) | ||
.verbosity(color_backtrace::Verbosity::Medium) | ||
.lib_verbosity(color_backtrace::Verbosity::Medium) | ||
.print_addresses(false) | ||
.install(default_output_stream()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters