Do not os.Exit() on "wire" and xmpp-proto errors, re-run main routine and helper goroutines

This commit is contained in:
eleksir
2023-08-05 20:02:10 -07:00
parent e8f8b3cb49
commit 267dd841a4
11 changed files with 606 additions and 220 deletions

29
buny.go
View File

@@ -1,7 +1,8 @@
package main
import (
"os"
"errors"
"fmt"
"regexp"
"strings"
@@ -84,8 +85,17 @@ func buny(v xmpp.Presence) error { //nolint:gocognit
"http://jabber.org/protocol/muc#admin",
ban,
); err != nil {
log.Errorf("Unable to ban user: id=%s, err=%s", id, err)
os.Exit(1)
err := errors.New(
fmt.Sprintf(
"Unable to ban user: id=%s, err=%s",
id,
err,
),
)
gTomb.Kill(err)
continue
}
return err
@@ -121,8 +131,17 @@ func buny(v xmpp.Presence) error { //nolint:gocognit
"http://jabber.org/protocol/muc#admin",
ban,
); err != nil {
log.Errorf("Unable to ban user: id=%s, err=%s", id, err)
os.Exit(1)
err := errors.New(
fmt.Sprintf(
"Unable to ban user: id=%s, err=%s",
id,
err,
),
)
gTomb.Kill(err)
continue
}
return err