diff options
author | Faye Duxovni <duxovni@duxovni.org> | 2023-04-03 17:27:00 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-03 23:27:00 +0200 |
commit | 6500714a93c6658749df8e477a729d9053f5c9b1 (patch) | |
tree | 027130082c92efaa33a4a0cc94a30fa85606193e /bridge/zulip | |
parent | 5feafcddbaee14965557584058389ca486f306b5 (diff) | |
download | matterbridge-msglm-6500714a93c6658749df8e477a729d9053f5c9b1.tar.gz matterbridge-msglm-6500714a93c6658749df8e477a729d9053f5c9b1.tar.bz2 matterbridge-msglm-6500714a93c6658749df8e477a729d9053f5c9b1.zip |
Don't treat nil as an unknown type of error (zulip) (#2024)
Fixes #1869
Diffstat (limited to 'bridge/zulip')
-rw-r--r-- | bridge/zulip/zulip.go | 45 |
1 files changed, 23 insertions, 22 deletions
diff --git a/bridge/zulip/zulip.go b/bridge/zulip/zulip.go index c912b6f0..9b8b73c2 100644 --- a/bridge/zulip/zulip.go +++ b/bridge/zulip/zulip.go @@ -106,30 +106,31 @@ func (b *Bzulip) getChannel(id int) string { func (b *Bzulip) handleQueue() error { for { messages, err := b.q.GetEvents() - switch err { - case gzb.BackoffError: - time.Sleep(time.Second * 5) - case gzb.NoJSONError: - b.Log.Error("Response wasn't JSON, server down or restarting? sleeping 10 seconds") - time.Sleep(time.Second * 10) - case gzb.BadEventQueueError: - b.Log.Info("got a bad event queue id error, reconnecting") - b.bot.Queues = nil - for { - b.q, err = b.bot.RegisterAll() - if err != nil { - b.Log.Errorf("reconnecting failed: %s. Sleeping 10 seconds", err) - time.Sleep(time.Second * 10) + if err != nil { + switch err { + case gzb.BackoffError: + time.Sleep(time.Second * 5) + case gzb.NoJSONError: + b.Log.Error("Response wasn't JSON, server down or restarting? sleeping 10 seconds") + time.Sleep(time.Second * 10) + case gzb.BadEventQueueError: + b.Log.Info("got a bad event queue id error, reconnecting") + b.bot.Queues = nil + for { + b.q, err = b.bot.RegisterAll() + if err != nil { + b.Log.Errorf("reconnecting failed: %s. Sleeping 10 seconds", err) + time.Sleep(time.Second * 10) + } + break } - break + case gzb.HeartbeatError: + b.Log.Debug("heartbeat received.") + default: + b.Log.Debugf("receiving error: %#v", err) + time.Sleep(time.Second * 10) } - case gzb.HeartbeatError: - b.Log.Debug("heartbeat received.") - default: - b.Log.Debugf("receiving error: %#v", err) - time.Sleep(time.Second * 10) - } - if err != nil { + continue } for _, m := range messages { |