From 5af1d8005509e42102b2e2c2319b1fd754bb46f3 Mon Sep 17 00:00:00 2001 From: Wim Date: Wed, 13 Feb 2019 00:29:34 +0100 Subject: Do not panic on non-json response from server (zulip) --- vendor/github.com/matterbridge/gozulipbot/queue.go | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'vendor/github.com/matterbridge/gozulipbot') diff --git a/vendor/github.com/matterbridge/gozulipbot/queue.go b/vendor/github.com/matterbridge/gozulipbot/queue.go index af32bb6e..d6e910ee 100644 --- a/vendor/github.com/matterbridge/gozulipbot/queue.go +++ b/vendor/github.com/matterbridge/gozulipbot/queue.go @@ -1,6 +1,7 @@ package gozulipbot import ( + "bytes" "encoding/json" "fmt" "io/ioutil" @@ -18,6 +19,7 @@ var ( BackoffError = fmt.Errorf("Too many requests") BadEventQueueError = fmt.Errorf("BAD_EVENT_QUEUE_ID error") UnknownError = fmt.Errorf("Error was unknown") + NoJSONError = fmt.Errorf("No JSON in body found") ) type Queue struct { @@ -150,6 +152,9 @@ func (q *Queue) GetEvents() ([]EventMessage, error) { case resp.StatusCode == 403: return nil, UnauthorizedError case resp.StatusCode >= 400: + if bytes.HasPrefix(body, []byte("<")) { + return nil, NoJSONError + } qErr, err := q.ParseError(body) if err != nil || qErr == nil { return nil, UnknownError -- cgit v1.2.3