Skip to content

Commit cdbb503

Browse files
remove unwrap
1 parent aaa581e commit cdbb503

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/api.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use crate::{
22
blocklist::{BlockList, FailedList, ListType, QueryInfo},
33
CARGO_PKG_NAME, CARGO_PKG_VERSION
44
};
5+
use anyhow::Context;
56
use log::info;
67
use poem::{
78
http::StatusCode,
@@ -230,14 +231,14 @@ pub(crate) async fn init(
230231
if path.exists() {
231232
// enusre that the file is really an unix socket and we do not delte something important
232233
let file = std::fs::File::open(path).unwrap();
233-
if file.metadata().unwrap().file_type().is_socket() {
234-
remove_file(&path).await.unwrap();
234+
if file.metadata().with_context(|| format!("failed to open file {path:?}"))?.file_type().is_socket() {
235+
remove_file(&path).await.with_context(|| format!("failed to remove existing socket {path:?}"))?;
235236
}
236237
}
237238
Server::new(UnixListener::bind(listener))
238239
.run(server)
239240
.await?;
240-
//todo remove file
241+
//todo remove file at drop
241242
} else {
242243
Server::new(TcpListener::bind(config.listener))
243244
.run(server)

0 commit comments

Comments
 (0)