Skip to content

Commit

Permalink
feat: panic! on error (#158)
Browse files Browse the repository at this point in the history
This aims at (i) correctly unwinding the stack on error, and (ii) returnin a
non-0 exit code to the system.
  • Loading branch information
delehef authored Feb 23, 2025
1 parent 09b4973 commit f53711d
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions lgn-worker/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit f53711d

Please sign in to comment.