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 |
| 11 | type ErrNeitherImageIDNorImageNameProvided struct{ *gophercloud.ErrMissingInput } |
| 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 |
| 19 | type ErrNeitherFlavorIDNorFlavorNameProvided struct{ *gophercloud.ErrMissingInput } |
| 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 | |
| 25 | // ErrInvalidHowParameterProvided is the error when an unknown value is given |
| 26 | // for the `how` argument |
| 27 | type ErrInvalidHowParameterProvided struct{ *gophercloud.ErrInvalidInput } |
| 28 | |
| 29 | // ErrNoAdminPassProvided is the error when an administrative password isn't |
| 30 | // provided for a server operation |
| 31 | type ErrNoAdminPassProvided struct{ *gophercloud.ErrMissingInput } |
| 32 | |
| 33 | // ErrNoImageIDProvided is the error when an image ID isn't provided for a server |
| 34 | // operation |
| 35 | type ErrNoImageIDProvided struct{ *gophercloud.ErrMissingInput } |
| 36 | |
| 37 | // ErrNoIDProvided is the error when a server ID isn't provided for a server |
| 38 | // operation |
| 39 | type ErrNoIDProvided struct{ *gophercloud.ErrMissingInput } |
| 40 | |
| 41 | // ErrServer is a generic error type for servers HTTP operations. |
| 42 | type ErrServer struct { |
| 43 | *gophercloud.ErrUnexpectedResponseCode |
| 44 | ID string |
| 45 | } |
| 46 | |
| 47 | func (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. |
| 52 | func (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. |
| 59 | type ErrServerNotFound struct { |
| 60 | *ErrServer |
| 61 | } |
| 62 | |
| 63 | func (e *ErrServerNotFound) Error() string { |
| 64 | return fmt.Sprintf("I couldn't find server [%s]", e.ID) |
| 65 | } |