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
1 changed files with 12 additions and 7 deletions

19
main.go
View File

@ -73,14 +73,19 @@ func main() {
for {
select {
case e := <-evnt:
ue := e.(*mastodon.UpdateEvent)
// https://pkg.go.dev/github.com/mattn/go-mastodon#Status
buf, err := json.MarshalIndent(ue.Status, "", " ")
if err != nil {
logrus.Error(err)
switch v := e.(type) {
case nil:
logrus.Info("event is nil")
case *mastodon.UpdateEvent:
// https://pkg.go.dev/github.com/mattn/go-mastodon#Status
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))
}
}
}