From fd8cfb11fb3d5e84ab44b14474b3421a1d49d1b1 Mon Sep 17 00:00:00 2001 From: Wim Date: Thu, 16 Mar 2017 23:05:11 +0100 Subject: Fail when bridge is unable to join a channel (general) --- bridge/bridge.go | 15 ++++++++++++--- gateway/gateway.go | 5 ++++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/bridge/bridge.go b/bridge/bridge.go index 312792b6..12fb71d7 100644 --- a/bridge/bridge.go +++ b/bridge/bridge.go @@ -84,8 +84,14 @@ func New(cfg *config.Config, bridge *config.Bridge, c chan config.Message) *Brid func (b *Bridge) JoinChannels() error { exists := make(map[string]bool) - b.joinChannels(b.ChannelsIn, exists) - b.joinChannels(b.ChannelsOut, exists) + err := b.joinChannels(b.ChannelsIn, exists) + if err != nil { + return err + } + err = b.joinChannels(b.ChannelsOut, exists) + if err != nil { + return err + } return nil } @@ -99,7 +105,10 @@ func (b *Bridge) joinChannels(cMap map[string]config.ChannelOptions, exists map[ log.Debugf("using key %s for channel %s", info.Key, channel) mychannel = mychannel + " " + info.Key } - b.JoinChannel(mychannel) + err := b.JoinChannel(mychannel) + if err != nil { + return err + } exists[channel] = true } } diff --git a/gateway/gateway.go b/gateway/gateway.go index 254fb89f..1f5c361f 100644 --- a/gateway/gateway.go +++ b/gateway/gateway.go @@ -48,7 +48,10 @@ func (gw *Gateway) AddBridge(cfg *config.Bridge) error { if err != nil { return fmt.Errorf("Bridge %s failed to start: %v", br.Account, err) } - br.JoinChannels() + err = br.JoinChannels() + if err != nil { + return fmt.Errorf("Bridge %s failed to join channel: %v", br.Account, err) + } return nil } -- cgit v1.2.3