*/src/main: exit on panic

This commit is contained in:
Astro 2021-12-07 17:08:30 +01:00
parent 633a418001
commit 41a57cd5f1
3 changed files with 21 additions and 0 deletions

View File

@ -26,6 +26,13 @@ fn update_max<T: Clone + PartialOrd>(value: &Option<T>, target: &mut Option<T>)
#[tokio::main]
async fn main() {
let orig_hook = std::panic::take_hook();
std::panic::set_hook(Box::new(move |panic_info| {
// invoke the default handler and exit the process
orig_hook(panic_info);
std::process::exit(1);
}));
let home = WGS84::from_degrees_and_meters(51.081, 13.728, 0.0);
let aircrafts = beast::aircrafts::Aircrafts::new();

View File

@ -18,6 +18,13 @@ impl std::error::Error for UsageError {}
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
let orig_hook = std::panic::take_hook();
std::panic::set_hook(Box::new(move |panic_info| {
// invoke the default handler and exit the process
orig_hook(panic_info);
std::process::exit(1);
}));
tokio::task::LocalSet::new().run_until(async move {
let aircrafts = aircrafts::Aircrafts::load("aircraftDatabase.csv");
let locations = location::Locations::load("locations.json");

View File

@ -34,6 +34,13 @@ impl Aircraft {
#[tokio::main]
async fn main() {
let orig_hook = std::panic::take_hook();
std::panic::set_hook(Box::new(move |panic_info| {
// invoke the default handler and exit the process
orig_hook(panic_info);
std::process::exit(1);
}));
let aircrafts = beast::aircrafts::Aircrafts::new();
aircrafts.connect("radiobert.serv.zentralwerk.org", 30005);