openstack errors
diff --git a/openstack/endpoint_location.go b/openstack/endpoint_location.go
index 1184b34..70f6800 100644
--- a/openstack/endpoint_location.go
+++ b/openstack/endpoint_location.go
@@ -1,8 +1,6 @@
package openstack
import (
- "fmt"
-
"github.com/gophercloud/gophercloud"
tokens2 "github.com/gophercloud/gophercloud/openstack/identity/v2/tokens"
tokens3 "github.com/gophercloud/gophercloud/openstack/identity/v3/tokens"
@@ -29,7 +27,10 @@
// Report an error if the options were ambiguous.
if len(endpoints) > 1 {
- return "", fmt.Errorf("Discovered %d matching endpoints: %#v", len(endpoints), endpoints)
+ err := &ErrMultipleMatchingEndpointsV2{}
+ err.Endpoints = endpoints
+ err.Function = "openstack.V2EndpointURL"
+ return "", err
}
// Extract the appropriate URL from the matching Endpoint.
@@ -42,12 +43,18 @@
case gophercloud.AvailabilityAdmin:
return gophercloud.NormalizeURL(endpoint.AdminURL), nil
default:
- return "", fmt.Errorf("Unexpected availability in endpoint query: %s", opts.Availability)
+ err := &ErrInvalidAvailabilityProvided{}
+ err.Function = "openstack.V2EndpointURL"
+ err.Argument = "Availability"
+ err.Value = opts.Availability
+ return "", err
}
}
// Report an error if there were no matching endpoints.
- return "", &gophercloud.ErrEndpointNotFound{}
+ err := &gophercloud.ErrEndpointNotFound{}
+ err.Function = "openstack.V2EndpointURL"
+ return "", err
}
// V3EndpointURL discovers the endpoint URL for a specific service from a Catalog acquired
@@ -66,7 +73,10 @@
if opts.Availability != gophercloud.AvailabilityAdmin &&
opts.Availability != gophercloud.AvailabilityPublic &&
opts.Availability != gophercloud.AvailabilityInternal {
- return "", fmt.Errorf("Unexpected availability in endpoint query: %s", opts.Availability)
+ err := &ErrInvalidAvailabilityProvided{}
+ err.Function = "openstack.V3EndpointURL"
+ err.Argument = "Availability"
+ err.Value = opts.Availability
}
if (opts.Availability == gophercloud.Availability(endpoint.Interface)) &&
(opts.Region == "" || endpoint.Region == opts.Region) {
@@ -78,7 +88,10 @@
// Report an error if the options were ambiguous.
if len(endpoints) > 1 {
- return "", fmt.Errorf("Discovered %d matching endpoints: %#v", len(endpoints), endpoints)
+ err := &ErrMultipleMatchingEndpointsV3{}
+ err.Endpoints = endpoints
+ err.Function = "openstack.V3EndpointURL"
+ return "", err
}
// Extract the URL from the matching Endpoint.
@@ -87,5 +100,7 @@
}
// Report an error if there were no matching endpoints.
- return "", &gophercloud.ErrEndpointNotFound{}
+ err := &gophercloud.ErrEndpointNotFound{}
+ err.Function = "openstack.V3EndpointURL"
+ return "", err
}