mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-26 08:45:16 +00:00
kucoin: check data pointer and return error
This commit is contained in:
parent
0c854a8a85
commit
8a00509987
|
@ -356,16 +356,20 @@ func (r *CancelOrderRequest) Do(ctx context.Context) (*CancelOrderResponse, erro
|
|||
return nil, err
|
||||
}
|
||||
|
||||
var orderResponse struct {
|
||||
var apiResponse struct {
|
||||
Code string `json:"code"`
|
||||
Message string `json:"msg"`
|
||||
Data *CancelOrderResponse `json:"data"`
|
||||
}
|
||||
if err := response.DecodeJSON(&orderResponse); err != nil {
|
||||
if err := response.DecodeJSON(&apiResponse); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return orderResponse.Data, nil
|
||||
if apiResponse.Data == nil {
|
||||
return nil, errors.New("api error: [" + apiResponse.Code + "] " + apiResponse.Message)
|
||||
}
|
||||
|
||||
return apiResponse.Data, nil
|
||||
}
|
||||
|
||||
type CancelAllOrderRequest struct {
|
||||
|
@ -392,17 +396,21 @@ func (r *CancelAllOrderRequest) Do(ctx context.Context) (*CancelOrderResponse, e
|
|||
return nil, err
|
||||
}
|
||||
|
||||
var orderResponse struct {
|
||||
var apiResponse struct {
|
||||
Code string `json:"code"`
|
||||
Message string `json:"msg"`
|
||||
Data *CancelOrderResponse `json:"data"`
|
||||
}
|
||||
|
||||
if err := response.DecodeJSON(&orderResponse); err != nil {
|
||||
if err := response.DecodeJSON(&apiResponse); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return orderResponse.Data, nil
|
||||
if apiResponse.Data == nil {
|
||||
return nil, errors.New("api error: [" + apiResponse.Code + "] " + apiResponse.Message)
|
||||
}
|
||||
|
||||
return apiResponse.Data, nil
|
||||
}
|
||||
|
||||
// Request via this endpoint to place 5 orders at the same time.
|
||||
|
|
Loading…
Reference in New Issue
Block a user