chore: Create try_main
to print the error message
Signed-off-by: Awiteb <a@4rs.nl>
This commit is contained in:
parent
245fcc705e
commit
b7b1f7e415
1 changed files with 11 additions and 6 deletions
17
src/main.rs
17
src/main.rs
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue