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:
parent
b300add154
commit
f956c6125d
1 changed files with 12 additions and 4 deletions
16
src/main.rs
16
src/main.rs
|
@ -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.")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue