From 8784407d7cb59178232c3ad3653e72642c7429a8 Mon Sep 17 00:00:00 2001 From: Nashira Deer Date: Tue, 16 Apr 2024 18:08:47 -0300 Subject: [PATCH] refactor: force exit instead of panicking --- src/main.rs | 6 +++--- src/manager.rs | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index 99fcca1..dc7c816 100644 --- a/src/main.rs +++ b/src/main.rs @@ -134,7 +134,7 @@ impl EventHandler for HydrogenHandler { if !register_commands(None, &ctx.http, &self.context.commands_id).await { error!("(ready): cannot register commands"); - panic!("cannot register commands"); + exit(1); } } @@ -333,7 +333,7 @@ async fn main() { Ok(v) => v, Err(e) => { error!("cannot initialize time parsers: {}", e); - panic!("cannot initialize time parsers"); + exit(1) } }); @@ -341,7 +341,7 @@ async fn main() { Ok(v) => v, Err(e) => { error!("cannot initialize roll parser: {}", e); - panic!("cannot initialize roll parser"); + exit(1); } }); diff --git a/src/manager.rs b/src/manager.rs index 80afc17..d5318af 100644 --- a/src/manager.rs +++ b/src/manager.rs @@ -1,6 +1,7 @@ use std::{ collections::HashMap, fmt::Display, + process::exit, result, sync::{ atomic::{AtomicUsize, Ordering}, @@ -761,7 +762,8 @@ impl LavalinkHandler for HydrogenManager { } if lavalink_nodes.len() == 0 { - panic!("(disconnect): no lavalink nodes connected."); + error!("(disconnect): no lavalink nodes connected."); + exit(1); } let mut players = self.player.write().await;