errors.go 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. package netutil
  2. import (
  3. "errors"
  4. "fmt"
  5. "strings"
  6. "github.com/storageos/go-api/serror"
  7. )
  8. // ErrAllFailed produces a typed StorageOS error which should be used to indicate that
  9. // the API is not contactable for all of the supplied node addresses.
  10. func ErrAllFailed(addrs []string) error {
  11. msg := fmt.Sprintf("failed to dial all known cluster members, (%s)", strings.Join(addrs, ","))
  12. help := "ensure that the value of $STORAGEOS_HOST (or the -H flag) is correct, and that there are healthy StorageOS nodes in this cluster"
  13. return serror.NewTypedStorageOSError(serror.APIUncontactable, nil, msg, help)
  14. }
  15. func newInvalidNodeError(err error) error {
  16. msg := fmt.Sprintf("invalid node format: %s", err)
  17. help := "please check the format of $STORAGEOS_HOST (or the -H flag) complies with the StorageOS JOIN format"
  18. return serror.NewTypedStorageOSError(serror.InvalidHostConfig, err, msg, help)
  19. }
  20. var (
  21. errUnsupportedScheme = errors.New("unsupported URL scheme")
  22. errInvalidHostName = errors.New("invalid hostname")
  23. errInvalidPortNumber = errors.New("invalid port number")
  24. )