diff --git a/main.go b/main.go index 60ca580..68d67be 100644 --- a/main.go +++ b/main.go @@ -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)) } } }