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 {
|
||||
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))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue