blob: ebfcdcd01b5f0003c344d4318d3c3e2aa4cbb345 [file] [log] [blame]
Jon Perritta33da232016-03-02 04:43:08 -06001package servers
2
3import (
4 "fmt"
5
6 "github.com/gophercloud/gophercloud"
7)
8
9// ErrNeitherImageIDNorImageNameProvided is the error when neither the image
10// ID nor the image name is provided for a server operation
11type ErrNeitherImageIDNorImageNameProvided struct{ *gophercloud.ErrMissingInput }
12
13func (e ErrNeitherImageIDNorImageNameProvided) Error() string {
14 return "One and only one of the image ID and the image name must be provided."
15}
16
17// ErrNeitherFlavorIDNorFlavorNameProvided is the error when neither the flavor
18// ID nor the flavor name is provided for a server operation
19type ErrNeitherFlavorIDNorFlavorNameProvided struct{ *gophercloud.ErrMissingInput }
20
21func (e ErrNeitherFlavorIDNorFlavorNameProvided) Error() string {
22 return "One and only one of the flavor ID and the flavor name must be provided."
23}
24
25// ErrInvalidHowParameterProvided is the error when an unknown value is given
26// for the `how` argument
27type ErrInvalidHowParameterProvided struct{ *gophercloud.ErrInvalidInput }
28
29// ErrNoAdminPassProvided is the error when an administrative password isn't
30// provided for a server operation
31type ErrNoAdminPassProvided struct{ *gophercloud.ErrMissingInput }
32
33// ErrNoImageIDProvided is the error when an image ID isn't provided for a server
34// operation
35type ErrNoImageIDProvided struct{ *gophercloud.ErrMissingInput }
36
37// ErrNoIDProvided is the error when a server ID isn't provided for a server
38// operation
39type ErrNoIDProvided struct{ *gophercloud.ErrMissingInput }
40
41// ErrServer is a generic error type for servers HTTP operations.
42type ErrServer struct {
43 *gophercloud.ErrUnexpectedResponseCode
44 ID string
45}
46
47func (se *ErrServer) Error() string {
48 return fmt.Sprintf("Error while executing HTTP request for server [%s]", se.ID)
49}
50
51// Error404 overrides the generic 404 error message.
52func (se *ErrServer) Error404(e *gophercloud.ErrUnexpectedResponseCode) error {
53 se.ErrUnexpectedResponseCode = e
54 return &ErrServerNotFound{se}
55}
56
57// ErrServerNotFound is the error when a 404 is received during server HTTP
58// operations.
59type ErrServerNotFound struct {
60 *ErrServer
61}
62
63func (e *ErrServerNotFound) Error() string {
64 return fmt.Sprintf("I couldn't find server [%s]", e.ID)
65}