github.com/vnpaycloud-console/gophercloud/v2@v2.0.5/openstack/objectstorage/v1/errors.go (about) 1 package v1 2 3 import ( 4 "fmt" 5 "strings" 6 7 "github.com/vnpaycloud-console/gophercloud/v2" 8 ) 9 10 func CheckContainerName(s string) error { 11 if len(s) < 1 { 12 return ErrEmptyContainerName{} 13 } 14 if strings.ContainsRune(s, '/') { 15 return ErrInvalidContainerName{name: s} 16 } 17 return nil 18 } 19 20 func CheckObjectName(s string) error { 21 if s == "" { 22 return ErrEmptyObjectName{} 23 } 24 return nil 25 } 26 27 // ErrInvalidContainerName signals a container name containing an illegal 28 // character. 29 type ErrInvalidContainerName struct { 30 name string 31 gophercloud.BaseError 32 } 33 34 func (e ErrInvalidContainerName) Error() string { 35 return fmt.Sprintf("invalid name %q: a container name cannot contain a slash (/) character", e.name) 36 } 37 38 // ErrEmptyContainerName signals an empty container name. 39 type ErrEmptyContainerName struct { 40 gophercloud.BaseError 41 } 42 43 func (e ErrEmptyContainerName) Error() string { 44 return "a container name must not be empty" 45 } 46 47 // ErrEmptyObjectName signals an empty container name. 48 type ErrEmptyObjectName struct { 49 gophercloud.BaseError 50 } 51 52 func (e ErrEmptyObjectName) Error() string { 53 return "an object name must not be empty" 54 }