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
19
main.go
19
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:
|
||||||
// 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))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue