From f53711d24a3817db5159307891f0e3a645b26f77 Mon Sep 17 00:00:00 2001 From: delehef Date: Sun, 23 Feb 2025 22:17:39 +0200 Subject: [PATCH] feat: panic! on error (#158) This aims at (i) correctly unwinding the stack on error, and (ii) returnin a non-0 exit code to the system. --- lgn-worker/src/main.rs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/lgn-worker/src/main.rs b/lgn-worker/src/main.rs index b5fc29a..fe246be 100644 --- a/lgn-worker/src/main.rs +++ b/lgn-worker/src/main.rs @@ -139,8 +139,7 @@ async fn main() -> anyhow::Result<()> { })); if let Err(err) = run(cli, mp2_requirement).await { - error!("{err:?}"); - bail!("Worker exited due to an error") + panic!("Worker exited due to an error: {err:?}") } else { Ok(()) } @@ -268,20 +267,19 @@ async fn run_worker( let msg = match inbound_message { Ok(ref msg) => msg, Err(e) => { - error!("connection to the gateway ended with status: {e}"); - break; + bail!("connection to the gateway ended with status: {e}"); } }; - let result = process_message_from_gateway(&mut provers_manager, msg, &mut outbound, &mp2_requirement).await ; + let result = process_message_from_gateway(&mut provers_manager, msg, &mut outbound, &mp2_requirement).await; if let Err(e) = result { - tracing::error!("task processing failed: {e:?}"); + bail!("task processing failed: {e:?}"); } } - else => break, + else => { + bail!("inbound connection broken"); + }, } } - - Ok(()) } fn process_downstream_payload(