Merge pull request #153 from behrang/master Add response parameters to error messages
Syfaro syfaro@huefox.com
Mon, 26 Mar 2018 11:19:46 -0500
M
bot.go
→
bot.go
@@ -79,7 +79,11 @@ log.Printf("%s resp: %s", endpoint, bytes)
} if !apiResp.Ok { - return apiResp, errors.New(apiResp.Description) + parameters := ResponseParameters{} + if apiResp.Parameters != nil { + parameters = *apiResp.Parameters + } + return apiResp, Error{apiResp.Description, parameters} } return apiResp, nil
M
types.go
→
types.go
@@ -410,7 +410,7 @@ CallbackData *string `json:"callback_data,omitempty"` // optional
SwitchInlineQuery *string `json:"switch_inline_query,omitempty"` // optional SwitchInlineQueryCurrentChat *string `json:"switch_inline_query_current_chat,omitempty"` // optional CallbackGame *CallbackGame `json:"callback_game,omitempty"` // optional - Pay bool `json:"pay,omitempty"` // optional + Pay bool `json:"pay,omitempty"` // optional } // CallbackQuery is data sent when a keyboard button with callback data@@ -771,3 +771,12 @@ InvoicePayload string `json:"invoice_payload"`
ShippingOptionID string `json:"shipping_option_id,omitempty"` OrderInfo *OrderInfo `json:"order_info,omitempty"` } + +type Error struct { + Message string + ResponseParameters +} + +func (e Error) Error() string { + return e.Message +}