blob: c9f0e3c20b5d515b7417096bd4a311f7d136a3b3 [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
Jon Perrittf094fef2016-03-07 01:41:59 -060011type ErrNeitherImageIDNorImageNameProvided struct{ gophercloud.ErrMissingInput }
Jon Perritta33da232016-03-02 04:43:08 -060012
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
Jon Perrittf094fef2016-03-07 01:41:59 -060019type ErrNeitherFlavorIDNorFlavorNameProvided struct{ gophercloud.ErrMissingInput }
Jon Perritta33da232016-03-02 04:43:08 -060020
21func (e ErrNeitherFlavorIDNorFlavorNameProvided) Error() string {
22 return "One and only one of the flavor ID and the flavor name must be provided."
23}
24
Jon Perrittf094fef2016-03-07 01:41:59 -060025type ErrNoClientProvidedForIDByName struct{ gophercloud.ErrMissingInput }
26
27func (e ErrNoClientProvidedForIDByName) Error() string {
28 return "A service client must be provided to find a resource ID by name."
29}
30
Jon Perritta33da232016-03-02 04:43:08 -060031// ErrInvalidHowParameterProvided is the error when an unknown value is given
32// for the `how` argument
Jon Perrittf094fef2016-03-07 01:41:59 -060033type ErrInvalidHowParameterProvided struct{ gophercloud.ErrInvalidInput }
Jon Perritta33da232016-03-02 04:43:08 -060034
35// ErrNoAdminPassProvided is the error when an administrative password isn't
36// provided for a server operation
Jon Perrittf094fef2016-03-07 01:41:59 -060037type ErrNoAdminPassProvided struct{ gophercloud.ErrMissingInput }
Jon Perritta33da232016-03-02 04:43:08 -060038
39// ErrNoImageIDProvided is the error when an image ID isn't provided for a server
40// operation
Jon Perrittf094fef2016-03-07 01:41:59 -060041type ErrNoImageIDProvided struct{ gophercloud.ErrMissingInput }
Jon Perritta33da232016-03-02 04:43:08 -060042
43// ErrNoIDProvided is the error when a server ID isn't provided for a server
44// operation
Jon Perrittf094fef2016-03-07 01:41:59 -060045type ErrNoIDProvided struct{ gophercloud.ErrMissingInput }
Jon Perritta33da232016-03-02 04:43:08 -060046
47// ErrServer is a generic error type for servers HTTP operations.
48type ErrServer struct {
Jon Perrittf094fef2016-03-07 01:41:59 -060049 gophercloud.ErrUnexpectedResponseCode
Jon Perritta33da232016-03-02 04:43:08 -060050 ID string
51}
52
Jon Perrittf094fef2016-03-07 01:41:59 -060053func (se ErrServer) Error() string {
Jon Perritta33da232016-03-02 04:43:08 -060054 return fmt.Sprintf("Error while executing HTTP request for server [%s]", se.ID)
55}
56
57// Error404 overrides the generic 404 error message.
Jon Perrittf094fef2016-03-07 01:41:59 -060058func (se ErrServer) Error404(e gophercloud.ErrUnexpectedResponseCode) error {
Jon Perritta33da232016-03-02 04:43:08 -060059 se.ErrUnexpectedResponseCode = e
60 return &ErrServerNotFound{se}
61}
62
63// ErrServerNotFound is the error when a 404 is received during server HTTP
64// operations.
65type ErrServerNotFound struct {
Jon Perrittf094fef2016-03-07 01:41:59 -060066 ErrServer
Jon Perritta33da232016-03-02 04:43:08 -060067}
68
Jon Perrittf094fef2016-03-07 01:41:59 -060069func (e ErrServerNotFound) Error() string {
Jon Perritta33da232016-03-02 04:43:08 -060070 return fmt.Sprintf("I couldn't find server [%s]", e.ID)
71}