Skip to content

Commit 617ab97

Browse files
A6GibKmbilelmoussaoui
authored andcommitted
server: Add context to errors in main
Without context the program will exit just saying, e.g. Error: File(LockedKeyring).
1 parent 38bfd11 commit 617ab97

1 file changed

Lines changed: 19 additions & 13 deletions

File tree

server/src/main.rs

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,7 @@ struct Args {
3737
is_verbose: bool,
3838
}
3939

40-
#[tokio::main]
41-
async fn main() -> Result<(), Error> {
42-
let args = Args::parse();
43-
44-
if args.is_verbose {
45-
tracing_subscriber::fmt()
46-
.with_max_level(tracing_subscriber::filter::LevelFilter::DEBUG)
47-
.init();
48-
tracing::debug!("Running in verbose mode");
49-
} else {
50-
tracing_subscriber::fmt::init();
51-
}
52-
40+
async fn inner_main(args: Args) -> Result<(), Error> {
5341
capability::drop_unnecessary_capabilities()?;
5442

5543
let secret = if args.login {
@@ -94,3 +82,21 @@ async fn main() -> Result<(), Error> {
9482

9583
Ok(())
9684
}
85+
86+
#[tokio::main]
87+
async fn main() -> Result<(), Error> {
88+
let args = Args::parse();
89+
90+
if args.is_verbose {
91+
tracing_subscriber::fmt()
92+
.with_max_level(tracing_subscriber::filter::LevelFilter::DEBUG)
93+
.init();
94+
tracing::debug!("Running in verbose mode");
95+
} else {
96+
tracing_subscriber::fmt::init();
97+
}
98+
99+
inner_main(args).await.inspect_err(|err| {
100+
tracing::error!("{err:#}");
101+
})
102+
}

0 commit comments

Comments
 (0)