From a6d3d96bd483afb752f8a8a038f1e287e9fbf1d9 Mon Sep 17 00:00:00 2001 From: Itamar Reif <9663129+itamarreif@users.noreply.github.com> Date: Fri, 19 Jul 2024 06:05:46 -0400 Subject: [PATCH] fix(bridge-withdrawer): don't panic on init (#1281) ## Summary Handle errors from constructing the service and emit an error. ## Background The service was set up to panic instead of emitting an error code and and message if initialization failed. ## Changes - Handle errors returned by service init rather than panicking and emit an event. ## Related Issues closes [#1278](https://github.com/astriaorg/astria/issues/1278) --- crates/astria-bridge-withdrawer/src/main.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/crates/astria-bridge-withdrawer/src/main.rs b/crates/astria-bridge-withdrawer/src/main.rs index 60b61e286b..89e6f6893c 100644 --- a/crates/astria-bridge-withdrawer/src/main.rs +++ b/crates/astria-bridge-withdrawer/src/main.rs @@ -52,8 +52,13 @@ async fn main() -> ExitCode { let mut sigterm = signal(SignalKind::terminate()) .expect("setting a SIGTERM listener should always work on Unix"); - let (withdrawer, shutdown_handle) = - BridgeWithdrawer::new(cfg).expect("could not initialize withdrawer"); + let (withdrawer, shutdown_handle) = match BridgeWithdrawer::new(cfg) { + Err(error) => { + error!(%error, "failed initializing bridge withdrawer"); + return ExitCode::FAILURE; + } + Ok(handles) => handles, + }; let withdrawer_handle = tokio::spawn(withdrawer.run()); let shutdown_token = shutdown_handle.token();