Merge pull request #153 from behrang/master

Add response parameters to error messages
bot-api-6.1
Syfaro 2018-03-26 11:19:46 -05:00 committed by GitHub
commit 38681a48d1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 2 deletions

6
bot.go
View File

@ -79,7 +79,11 @@ func (bot *BotAPI) MakeRequest(endpoint string, params url.Values) (APIResponse,
} }
if !apiResp.Ok { 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 return apiResp, nil

View File

@ -771,3 +771,12 @@ type PreCheckoutQuery struct {
ShippingOptionID string `json:"shipping_option_id,omitempty"` ShippingOptionID string `json:"shipping_option_id,omitempty"`
OrderInfo *OrderInfo `json:"order_info,omitempty"` OrderInfo *OrderInfo `json:"order_info,omitempty"`
} }
type Error struct {
Message string
ResponseParameters
}
func (e Error) Error() string {
return e.Message
}