mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-19 07:26:49 +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:
@@ -2046,7 +2046,7 @@ func (s *RPCServer) SetExchangePair(_ context.Context, r *gctrpc.SetExchangePair
|
||||
return nil, err
|
||||
}
|
||||
var pass bool
|
||||
var newErrors common.Errors
|
||||
var newErrors error
|
||||
for i := range r.Pairs {
|
||||
var p currency.Pair
|
||||
p, err = currency.NewPairFromStrings(r.Pairs[i].Base, r.Pairs[i].Quote)
|
||||
@@ -2057,12 +2057,12 @@ func (s *RPCServer) SetExchangePair(_ context.Context, r *gctrpc.SetExchangePair
|
||||
if r.Enable {
|
||||
err = exchCfg.CurrencyPairs.EnablePair(a, p.Format(pairFmt))
|
||||
if err != nil {
|
||||
newErrors = append(newErrors, fmt.Errorf("%s %w", r.Pairs[i], err))
|
||||
newErrors = common.AppendError(newErrors, fmt.Errorf("%s %w", r.Pairs[i], err))
|
||||
continue
|
||||
}
|
||||
err = base.CurrencyPairs.EnablePair(a, p)
|
||||
if err != nil {
|
||||
newErrors = append(newErrors, fmt.Errorf("%s %w", r.Pairs[i], err))
|
||||
newErrors = common.AppendError(newErrors, fmt.Errorf("%s %w", r.Pairs[i], err))
|
||||
continue
|
||||
}
|
||||
pass = true
|
||||
@@ -2072,7 +2072,7 @@ func (s *RPCServer) SetExchangePair(_ context.Context, r *gctrpc.SetExchangePair
|
||||
err = exchCfg.CurrencyPairs.DisablePair(a, p.Format(pairFmt))
|
||||
if err != nil {
|
||||
if errors.Is(err, currency.ErrPairNotFound) {
|
||||
newErrors = append(newErrors, fmt.Errorf("%s %w", r.Pairs[i], errSpecificPairNotEnabled))
|
||||
newErrors = common.AppendError(newErrors, fmt.Errorf("%s %w", r.Pairs[i], errSpecificPairNotEnabled))
|
||||
continue
|
||||
}
|
||||
return nil, err
|
||||
@@ -2081,7 +2081,7 @@ func (s *RPCServer) SetExchangePair(_ context.Context, r *gctrpc.SetExchangePair
|
||||
err = base.CurrencyPairs.DisablePair(a, p)
|
||||
if err != nil {
|
||||
if errors.Is(err, currency.ErrPairNotFound) {
|
||||
newErrors = append(newErrors, fmt.Errorf("%s %w", r.Pairs[i], errSpecificPairNotEnabled))
|
||||
newErrors = common.AppendError(newErrors, fmt.Errorf("%s %w", r.Pairs[i], errSpecificPairNotEnabled))
|
||||
continue
|
||||
}
|
||||
return nil, err
|
||||
@@ -2092,7 +2092,7 @@ func (s *RPCServer) SetExchangePair(_ context.Context, r *gctrpc.SetExchangePair
|
||||
if exch.IsWebsocketEnabled() && pass && base.Websocket.IsConnected() {
|
||||
err = exch.FlushWebsocketChannels()
|
||||
if err != nil {
|
||||
newErrors = append(newErrors, err)
|
||||
newErrors = common.AppendError(newErrors, err)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user