Jon Perritt | a33da23 | 2016-03-02 04:43:08 -0600 | [diff] [blame] | 1 | package servers |
| 2 | |
| 3 | import ( |
| 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 Perritt | f094fef | 2016-03-07 01:41:59 -0600 | [diff] [blame] | 11 | type ErrNeitherImageIDNorImageNameProvided struct{ gophercloud.ErrMissingInput } |
Jon Perritt | a33da23 | 2016-03-02 04:43:08 -0600 | [diff] [blame] | 12 | |
| 13 | func (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 Perritt | f094fef | 2016-03-07 01:41:59 -0600 | [diff] [blame] | 19 | type ErrNeitherFlavorIDNorFlavorNameProvided struct{ gophercloud.ErrMissingInput } |
Jon Perritt | a33da23 | 2016-03-02 04:43:08 -0600 | [diff] [blame] | 20 | |
| 21 | func (e ErrNeitherFlavorIDNorFlavorNameProvided) Error() string { |
| 22 | return "One and only one of the flavor ID and the flavor name must be provided." |
| 23 | } |
| 24 | |
Jon Perritt | f094fef | 2016-03-07 01:41:59 -0600 | [diff] [blame] | 25 | type ErrNoClientProvidedForIDByName struct{ gophercloud.ErrMissingInput } |
| 26 | |
| 27 | func (e ErrNoClientProvidedForIDByName) Error() string { |
| 28 | return "A service client must be provided to find a resource ID by name." |
| 29 | } |
| 30 | |
Jon Perritt | a33da23 | 2016-03-02 04:43:08 -0600 | [diff] [blame] | 31 | // ErrInvalidHowParameterProvided is the error when an unknown value is given |
| 32 | // for the `how` argument |
Jon Perritt | f094fef | 2016-03-07 01:41:59 -0600 | [diff] [blame] | 33 | type ErrInvalidHowParameterProvided struct{ gophercloud.ErrInvalidInput } |
Jon Perritt | a33da23 | 2016-03-02 04:43:08 -0600 | [diff] [blame] | 34 | |
| 35 | // ErrNoAdminPassProvided is the error when an administrative password isn't |
| 36 | // provided for a server operation |
Jon Perritt | f094fef | 2016-03-07 01:41:59 -0600 | [diff] [blame] | 37 | type ErrNoAdminPassProvided struct{ gophercloud.ErrMissingInput } |
Jon Perritt | a33da23 | 2016-03-02 04:43:08 -0600 | [diff] [blame] | 38 | |
| 39 | // ErrNoImageIDProvided is the error when an image ID isn't provided for a server |
| 40 | // operation |
Jon Perritt | f094fef | 2016-03-07 01:41:59 -0600 | [diff] [blame] | 41 | type ErrNoImageIDProvided struct{ gophercloud.ErrMissingInput } |
Jon Perritt | a33da23 | 2016-03-02 04:43:08 -0600 | [diff] [blame] | 42 | |
| 43 | // ErrNoIDProvided is the error when a server ID isn't provided for a server |
| 44 | // operation |
Jon Perritt | f094fef | 2016-03-07 01:41:59 -0600 | [diff] [blame] | 45 | type ErrNoIDProvided struct{ gophercloud.ErrMissingInput } |
Jon Perritt | a33da23 | 2016-03-02 04:43:08 -0600 | [diff] [blame] | 46 | |
| 47 | // ErrServer is a generic error type for servers HTTP operations. |
| 48 | type ErrServer struct { |
Jon Perritt | f094fef | 2016-03-07 01:41:59 -0600 | [diff] [blame] | 49 | gophercloud.ErrUnexpectedResponseCode |
Jon Perritt | a33da23 | 2016-03-02 04:43:08 -0600 | [diff] [blame] | 50 | ID string |
| 51 | } |
| 52 | |
Jon Perritt | f094fef | 2016-03-07 01:41:59 -0600 | [diff] [blame] | 53 | func (se ErrServer) Error() string { |
Jon Perritt | a33da23 | 2016-03-02 04:43:08 -0600 | [diff] [blame] | 54 | return fmt.Sprintf("Error while executing HTTP request for server [%s]", se.ID) |
| 55 | } |
| 56 | |
| 57 | // Error404 overrides the generic 404 error message. |
Jon Perritt | f094fef | 2016-03-07 01:41:59 -0600 | [diff] [blame] | 58 | func (se ErrServer) Error404(e gophercloud.ErrUnexpectedResponseCode) error { |
Jon Perritt | a33da23 | 2016-03-02 04:43:08 -0600 | [diff] [blame] | 59 | se.ErrUnexpectedResponseCode = e |
| 60 | return &ErrServerNotFound{se} |
| 61 | } |
| 62 | |
| 63 | // ErrServerNotFound is the error when a 404 is received during server HTTP |
| 64 | // operations. |
| 65 | type ErrServerNotFound struct { |
Jon Perritt | f094fef | 2016-03-07 01:41:59 -0600 | [diff] [blame] | 66 | ErrServer |
Jon Perritt | a33da23 | 2016-03-02 04:43:08 -0600 | [diff] [blame] | 67 | } |
| 68 | |
Jon Perritt | f094fef | 2016-03-07 01:41:59 -0600 | [diff] [blame] | 69 | func (e ErrServerNotFound) Error() string { |
Jon Perritt | a33da23 | 2016-03-02 04:43:08 -0600 | [diff] [blame] | 70 | return fmt.Sprintf("I couldn't find server [%s]", e.ID) |
| 71 | } |