merge: pull request #565 from HigherOrderCO/564-new-panic-hook-for-the-language

Panic hook
This commit is contained in:
Sofia Rodrigues 2023-05-08 20:21:19 -03:00 committed by GitHub
commit 2d0cda4faa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,3 +1,5 @@
#![feature(panic_info_message)]
use std::path::PathBuf;
use std::time::Instant;
use std::{fmt, io};
@ -8,6 +10,7 @@ use kind_driver::session::Session;
use kind_report::data::{Diagnostic, FileCache, Log, Severity};
use kind_report::RenderConfig;
use std::panic;
use kind_driver as driver;
@ -354,6 +357,13 @@ pub fn run_cli(config: Cli) -> anyhow::Result<()> {
}
pub fn main() {
panic::set_hook(Box::new(|e| {
println!("\n[Error]: internal compiler error '{:?}' at {}", e.message().unwrap(), e.location().unwrap());
println!("Please submit a full report about this error at: https://github.com/HigherOrderCO/Kind/issues/new");
println!("It would help us a lot :)\n");
}));
match run_cli(Cli::parse()) {
Ok(_) => std::process::exit(0),
Err(_) => std::process::exit(1),