Skip to content

Commit

Permalink
brokers/manager: Run cleanup function, if any, on errors
Browse files Browse the repository at this point in the history
  • Loading branch information
3v1n0 committed Nov 21, 2024
1 parent ea14639 commit 4bd8ec9
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion internal/brokers/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,17 @@ func NewManager(ctx context.Context, brokersConfPath string, configuredBrokers [
brokersConfPathWithExample, cleanup, err := useExampleBrokers()
if err != nil {
return nil, err
} else if brokersConfPathWithExample != "" {
}
if brokersConfPathWithExample != "" {
brokersConfPath = brokersConfPathWithExample
}

defer func() {
if err != nil && cleanup != nil {
cleanup()
}
}()

// Connect to the system bus
// Don't call dbus.SystemBus which caches globally system dbus (issues in tests)
bus, err := dbus.ConnectSystemBus()
Expand Down

0 comments on commit 4bd8ec9

Please sign in to comment.