mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-06-01 23:16:51 +00:00
FTX: order cancellation improvement (#727)
* exchanges/request: Requester.doRequest() now always parses returned response body into JSON even in the case of an artificial error after the request itself * exchanges/ftx: consider order cancellation successful under two new conditions, reported by the exchange: (1) order is already closed or (2) order is already queued for cancellation * exchanges/ftx: fix a typo in a comment * exchanges/request: keep the same behavior of doRequest() when there is an unmarshaling error * exchanges/ftx: FTX.DeleteOrderByClientID now also reports no errors when requesting the cancellation of orders that are already canceled on the exchange * exchanges/ftx: order deletion methods are now unified * exchanges/ftx: DeleteOrder* methods now check if the given ID is not empty
This commit is contained in:
@@ -197,6 +197,12 @@ func (r *Requester) doRequest(req *http.Request, p *Item) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// Even in the case of an erroneous condition below, yield the parsed
|
||||
// response to caller.
|
||||
var unmarshallError error
|
||||
if p.Result != nil {
|
||||
unmarshallError = json.Unmarshal(contents, p.Result)
|
||||
}
|
||||
|
||||
if p.HTTPRecording {
|
||||
// This dumps http responses for future mocking implementations
|
||||
@@ -242,10 +248,7 @@ func (r *Requester) doRequest(req *http.Request, p *Item) error {
|
||||
string(contents))
|
||||
}
|
||||
}
|
||||
if p.Result != nil {
|
||||
return json.Unmarshal(contents, p.Result)
|
||||
}
|
||||
return nil
|
||||
return unmarshallError
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user