main: sometimes events can be errors
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
This commit is contained in:
parent
cf28b35428
commit
dc6494d20c
1 changed files with 12 additions and 7 deletions
11
main.go
11
main.go
|
@ -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:
|
||||||
|
logrus.Info("event is nil")
|
||||||
|
case *mastodon.UpdateEvent:
|
||||||
// https://pkg.go.dev/github.com/mattn/go-mastodon#Status
|
// https://pkg.go.dev/github.com/mattn/go-mastodon#Status
|
||||||
buf, err := json.MarshalIndent(ue.Status, "", " ")
|
buf, err := json.MarshalIndent(v.Status, "", " ")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Error(err)
|
logrus.Error(err)
|
||||||
}
|
}
|
||||||
fmt.Println(string(buf))
|
fmt.Println(string(buf))
|
||||||
|
case *mastodon.ErrorEvent:
|
||||||
|
logrus.Errorf("event was error: %#v", v)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue