Skip to content

Commit

Permalink
Replaced unwraps in main with error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
voidc committed Aug 26, 2020
1 parent 71367ff commit 486a9c8
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use anyhow::Context;
use api::protocol::*;
use bytes::Bytes;
use futures::stream::StreamExt;
use log::{info, trace, warn};
use log::{error, info, trace, warn};
use onion::*;
use ring::rand;
use std::collections::HashMap;
Expand Down Expand Up @@ -250,15 +250,19 @@ async fn main() -> Result<()> {
let api_handler = onion_module.clone();
let api_addr = config.onion.api_address;
async move {
api_handler.listen_api(api_addr, onion).await.unwrap();
if let Err(e) = api_handler.listen_api(api_addr, onion).await {
error!("API handler failed: {}", e);
}
}
});

// TODO maybe one task for incoming and events (select), no mutex on connections required?
let event_task = tokio::spawn({
let event_handler = onion_module.clone();
async move {
event_handler.handle_events(events).await.unwrap();
if let Err(e) = event_handler.handle_events(events).await {
error!("Event handler failed: {}", e);
}
}
});

Expand Down

0 comments on commit 486a9c8

Please sign in to comment.