1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-22 11:04:21 +00:00

Handle both the Ok and the Err case of try_join!

This commit is contained in:
Steffo 2024-07-11 06:38:16 +02:00
parent b300add154
commit f956c6125d
Signed by: steffo
GPG key ID: 5ADA3868646C3FC0

View file

@ -1,4 +1,4 @@
use anyhow::{Result}; use anyhow::Result;
use crate::telegram::DispatchWithResult; use crate::telegram::DispatchWithResult;
pub(crate) mod database; pub(crate) mod database;
@ -17,11 +17,19 @@ async fn main() -> Result<()> {
// Run all services concurrently // Run all services concurrently
log::info!("Starting services..."); log::info!("Starting services...");
tokio::try_join![ let result = tokio::try_join![
telegram_awaitable, telegram_awaitable,
]; ];
// This should never happen, but just in case... // This should never happen, but just in case...
log::error!("A service has exited, bailing out..."); match result {
anyhow::bail!("A service has exited.") Err(error) => {
log::error!("A service has exited with an error, bailing out: {error:?}");
anyhow::bail!("A service has exited with an error.")
},
_ => {
log::error!("All service have exited successfully, bailing out...");
anyhow::bail!("All service have exited successfully.")
}
}
} }