Skip to content

Commit

Permalink
fix(bridge-withdrawer): don't panic on init (#1281)
Browse files Browse the repository at this point in the history
## 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](#1278)
  • Loading branch information
itamarreif committed Jul 19, 2024
1 parent 23e45be commit a6d3d96
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions crates/astria-bridge-withdrawer/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit a6d3d96

Please sign in to comment.