mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-31 23:16:54 +00:00
common: update Errors type (#1129)
* common: adjust common error slice to allow multi errors.Is matching and conform to interface better * zb: forgot to save? * linties: fixies * linties: word change as well. * nitters: glorious * buts * nitters: fix glorious bug * Update common/common.go Co-authored-by: Scott <gloriousCode@users.noreply.github.com> * nitters: shifty --------- Co-authored-by: Ryan O'Hara-Reid <ryan.oharareid@thrasher.io> Co-authored-by: Scott <gloriousCode@users.noreply.github.com>
This commit is contained in:
@@ -498,7 +498,7 @@ func (h *HitBTC) GenerateDefaultSubscriptions() ([]stream.ChannelSubscription, e
|
||||
|
||||
// Subscribe sends a websocket message to receive data from the channel
|
||||
func (h *HitBTC) Subscribe(channelsToSubscribe []stream.ChannelSubscription) error {
|
||||
var errs common.Errors
|
||||
var errs error
|
||||
for i := range channelsToSubscribe {
|
||||
subscribe := WsRequest{
|
||||
Method: channelsToSubscribe[i].Channel,
|
||||
@@ -517,7 +517,7 @@ func (h *HitBTC) Subscribe(channelsToSubscribe []stream.ChannelSubscription) err
|
||||
|
||||
err := h.Websocket.Conn.SendJSONMessage(subscribe)
|
||||
if err != nil {
|
||||
errs = append(errs, err)
|
||||
errs = common.AppendError(errs, err)
|
||||
continue
|
||||
}
|
||||
h.Websocket.AddSuccessfulSubscriptions(channelsToSubscribe[i])
|
||||
@@ -530,7 +530,7 @@ func (h *HitBTC) Subscribe(channelsToSubscribe []stream.ChannelSubscription) err
|
||||
|
||||
// Unsubscribe sends a websocket message to stop receiving data from the channel
|
||||
func (h *HitBTC) Unsubscribe(channelsToUnsubscribe []stream.ChannelSubscription) error {
|
||||
var errs common.Errors
|
||||
var errs error
|
||||
for i := range channelsToUnsubscribe {
|
||||
unsubscribeChannel := strings.Replace(channelsToUnsubscribe[i].Channel,
|
||||
"subscribe",
|
||||
@@ -552,7 +552,7 @@ func (h *HitBTC) Unsubscribe(channelsToUnsubscribe []stream.ChannelSubscription)
|
||||
|
||||
err := h.Websocket.Conn.SendJSONMessage(unsubscribe)
|
||||
if err != nil {
|
||||
errs = append(errs, err)
|
||||
errs = common.AppendError(errs, err)
|
||||
continue
|
||||
}
|
||||
h.Websocket.RemoveSuccessfulUnsubscriptions(channelsToUnsubscribe[i])
|
||||
|
||||
Reference in New Issue
Block a user