diff options
author | Wim <wim@42.be> | 2019-02-13 00:29:34 +0100 |
---|---|---|
committer | Wim <wim@42.be> | 2019-02-13 00:29:34 +0100 |
commit | 5af1d8005509e42102b2e2c2319b1fd754bb46f3 (patch) | |
tree | 5d2673ca96f3232fbdf9f0cefc913dbbde293220 /vendor | |
parent | f236d12166a8ae186b251fee15b88d774dabc69c (diff) | |
download | matterbridge-msglm-5af1d8005509e42102b2e2c2319b1fd754bb46f3.tar.gz matterbridge-msglm-5af1d8005509e42102b2e2c2319b1fd754bb46f3.tar.bz2 matterbridge-msglm-5af1d8005509e42102b2e2c2319b1fd754bb46f3.zip |
Do not panic on non-json response from server (zulip)
Diffstat (limited to 'vendor')
-rw-r--r-- | vendor/github.com/matterbridge/gozulipbot/queue.go | 5 | ||||
-rw-r--r-- | vendor/modules.txt | 2 |
2 files changed, 6 insertions, 1 deletions
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 diff --git a/vendor/modules.txt b/vendor/modules.txt index 1b268fcb..d01d5147 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -70,7 +70,7 @@ github.com/magiconair/properties github.com/matterbridge/go-xmpp # github.com/matterbridge/gomatrix v0.0.0-20190102230110-6f9631ca6dea github.com/matterbridge/gomatrix -# github.com/matterbridge/gozulipbot v0.0.0-20190211002717-befe50663a92 +# github.com/matterbridge/gozulipbot v0.0.0-20190212232658-7aa251978a18 github.com/matterbridge/gozulipbot # github.com/matterbridge/logrus-prefixed-formatter v0.0.0-20180806162718-01618749af61 github.com/matterbridge/logrus-prefixed-formatter |