backend.FilterIPs should return differentiable error - whether this is a 
transient or a permanent error.
I'd use github.com/pkg/errors:

var ErrTransient = errors.New("transient error")

...

func FilterIPs(...) error {
  if err != nil && err.IsTemporary() {
    return errors.Wrap(ErrTransient, err.Error()
  }
  ...
}

or just wrap make the error transient:

type Transient interface {
  Temporary() bool
}
func IsTemporary(err error) bool {
  if tr, _ := err.(Transient); tr != nil {
    return tr.Temporary()
  }
  return false
}

...

func FilterIPs(...) error {
  if err != nil && err.IsTemporary() {
    return &transientErr{err}
  }
  ...
}

var _ = ((*transientErr)(nil)).(Transient)
type transientErr struct {
  err error
}
func (tr *transientErr) Error() string { return tr.err.Error() }
func (tr *transientErr) Temporary() bool { return true }

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to