all repos — telegram-bot-api @ 9f98d19464ddfabe93b1939a64538e4b6fbb9ad0

Golang bindings for the Telegram Bot API

Merge pull request #72 from uamana/FIX_error_handling

Fix returning APIResponse from SetWebHook
Syfaro syfaro@foxpaw.in
Wed, 19 Apr 2017 15:44:18 -0500
commit

9f98d19464ddfabe93b1939a64538e4b6fbb9ad0

parent

ff42d6f7d1787d267bedf28764f69107820dd0fa

1 files changed, 6 insertions(+), 9 deletions(-)

jump to
M bot.gobot.go

@@ -191,7 +191,11 @@ log.Println(string(bytes))

} var apiResp APIResponse - json.Unmarshal(bytes, &apiResp) + + err = json.Unmarshal(bytes, &apiResp) + if err != nil { + return APIResponse{}, err + } if !apiResp.Ok { return APIResponse{}, errors.New(apiResp.Description)

@@ -438,14 +442,7 @@ if err != nil {

return APIResponse{}, err } - var apiResp APIResponse - json.Unmarshal(resp.Result, &apiResp) - - if bot.Debug { - log.Printf("setWebhook resp: %+v\n", apiResp) - } - - return apiResp, nil + return resp, nil } // GetWebhookInfo allows you to fetch information about a webhook and if