more error types for compute v2
diff --git a/openstack/compute/v2/extensions/schedulerhints/requests.go b/openstack/compute/v2/extensions/schedulerhints/requests.go
index d9aa733..5713e72 100644
--- a/openstack/compute/v2/extensions/schedulerhints/requests.go
+++ b/openstack/compute/v2/extensions/schedulerhints/requests.go
@@ -1,11 +1,11 @@
package schedulerhints
import (
- "fmt"
"net"
"regexp"
"strings"
+ "github.com/gophercloud/gophercloud"
"github.com/gophercloud/gophercloud/openstack/compute/v2/servers"
)
@@ -47,7 +47,12 @@
if opts.Group != "" {
if !uuidRegex.MatchString(opts.Group) {
- return nil, fmt.Errorf("Group must be a UUID")
+ err := gophercloud.ErrInvalidInput{}
+ err.Function = "schedulerhints.ToServerSchedulerHintsMap"
+ err.Argument = "schedulerhints.SchedulerHints.Group"
+ err.Value = opts.Group
+ err.Info = "Group must be a UUID"
+ return nil, err
}
sh["group"] = opts.Group
}
@@ -55,7 +60,12 @@
if len(opts.DifferentHost) > 0 {
for _, diffHost := range opts.DifferentHost {
if !uuidRegex.MatchString(diffHost) {
- return nil, fmt.Errorf("The hosts in DifferentHost must be in UUID format.")
+ err := gophercloud.ErrInvalidInput{}
+ err.Function = "schedulerhints.ToServerSchedulerHintsMap"
+ err.Argument = "schedulerhints.SchedulerHints.DifferentHost"
+ err.Value = opts.DifferentHost
+ err.Info = "The hosts must be in UUID format."
+ return nil, err
}
}
sh["different_host"] = opts.DifferentHost
@@ -64,7 +74,12 @@
if len(opts.SameHost) > 0 {
for _, sameHost := range opts.SameHost {
if !uuidRegex.MatchString(sameHost) {
- return nil, fmt.Errorf("The hosts in SameHost must be in UUID format.")
+ err := gophercloud.ErrInvalidInput{}
+ err.Function = "schedulerhints.ToServerSchedulerHintsMap"
+ err.Argument = "schedulerhints.SchedulerHints.SameHost"
+ err.Value = opts.SameHost
+ err.Info = "The hosts must be in UUID format."
+ return nil, err
}
}
sh["same_host"] = opts.SameHost
@@ -83,7 +98,12 @@
*/
if len(opts.Query) > 0 {
if len(opts.Query) < 3 {
- return nil, fmt.Errorf("Query must be a conditional statement in the format of [op,variable,value]")
+ err := gophercloud.ErrInvalidInput{}
+ err.Function = "schedulerhints.ToServerSchedulerHintsMap"
+ err.Argument = "schedulerhints.SchedulerHints.Query"
+ err.Value = opts.Query
+ err.Info = "Must be a conditional statement in the format of [op,variable,value]"
+ return nil, err
}
sh["query"] = opts.Query
}
@@ -94,7 +114,12 @@
if opts.BuildNearHostIP != "" {
if _, _, err := net.ParseCIDR(opts.BuildNearHostIP); err != nil {
- return nil, fmt.Errorf("BuildNearHostIP must be a valid subnet in the form 192.168.1.1/24")
+ err := gophercloud.ErrInvalidInput{}
+ err.Function = "schedulerhints.ToServerSchedulerHintsMap"
+ err.Argument = "schedulerhints.SchedulerHints.BuildNearHostIP"
+ err.Value = opts.BuildNearHostIP
+ err.Info = "Must be a valid subnet in the form 192.168.1.1/24"
+ return nil, err
}
ipParts := strings.Split(opts.BuildNearHostIP, "/")
sh["build_near_host_ip"] = ipParts[0]