main: sometimes events can be errors

Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
This commit is contained in:
Vincent Batts 2023-03-14 16:08:19 -04:00
parent cf28b35428
commit dc6494d20c
Signed by: vbatts
GPG key ID: 10937E57733F1362

19
main.go
View file

@ -73,14 +73,19 @@ func main() {
for { for {
select { select {
case e := <-evnt: case e := <-evnt:
ue := e.(*mastodon.UpdateEvent) switch v := e.(type) {
case nil:
// https://pkg.go.dev/github.com/mattn/go-mastodon#Status logrus.Info("event is nil")
buf, err := json.MarshalIndent(ue.Status, "", " ") case *mastodon.UpdateEvent:
if err != nil { // https://pkg.go.dev/github.com/mattn/go-mastodon#Status
logrus.Error(err) buf, err := json.MarshalIndent(v.Status, "", " ")
if err != nil {
logrus.Error(err)
}
fmt.Println(string(buf))
case *mastodon.ErrorEvent:
logrus.Errorf("event was error: %#v", v)
} }
fmt.Println(string(buf))
} }
} }
} }