chore: Create try_main to print the error message

Signed-off-by: Awiteb <a@4rs.nl>
This commit is contained in:
Awiteb 2024-05-29 22:45:07 +03:00
parent 245fcc705e
commit b7b1f7e415
Signed by: awiteb
GPG key ID: 3F6B55640AA6682F

View file

@ -16,7 +16,7 @@
#![doc = include_str!("../README.md")]
use std::{env, fs, sync::Mutex};
use std::{env, fs, process::ExitCode, sync::Mutex};
use lazy_static::lazy_static;
use salvo::{conn::TcpListener, Listener};
@ -52,15 +52,11 @@ impl PingedBot {
}
}
#[allow(clippy::absolute_paths)]
type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>;
lazy_static! {
static ref PINGED_BOTS: Mutex<Vec<PingedBot>> = Mutex::new(Vec::new());
}
#[tokio::main]
async fn main() -> Result<()> {
async fn try_main() -> ServerResult<()> {
pretty_env_logger::init();
dotenv::dotenv().ok();
log::info!("Starting the API");
@ -120,3 +116,12 @@ async fn main() -> Result<()> {
}
Ok(())
}
#[tokio::main]
async fn main() -> ExitCode {
if let Err(err) = try_main().await {
eprintln!("{err}");
return ExitCode::FAILURE;
}
ExitCode::SUCCESS
}