github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/compute/v2/servers/errors.go (about) 1 package servers 2 3 import ( 4 "fmt" 5 6 "github.com/huaweicloud/golangsdk" 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{ golangsdk.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{ golangsdk.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 type ErrNoClientProvidedForIDByName struct{ golangsdk.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 31 // ErrInvalidHowParameterProvided is the error when an unknown value is given 32 // for the `how` argument 33 type ErrInvalidHowParameterProvided struct{ golangsdk.ErrInvalidInput } 34 35 // ErrNoAdminPassProvided is the error when an administrative password isn't 36 // provided for a server operation 37 type ErrNoAdminPassProvided struct{ golangsdk.ErrMissingInput } 38 39 // ErrNoImageIDProvided is the error when an image ID isn't provided for a server 40 // operation 41 type ErrNoImageIDProvided struct{ golangsdk.ErrMissingInput } 42 43 // ErrNoIDProvided is the error when a server ID isn't provided for a server 44 // operation 45 type ErrNoIDProvided struct{ golangsdk.ErrMissingInput } 46 47 // ErrServer is a generic error type for servers HTTP operations. 48 type ErrServer struct { 49 golangsdk.ErrUnexpectedResponseCode 50 ID string 51 } 52 53 func (se ErrServer) Error() string { 54 return fmt.Sprintf("Error while executing HTTP request for server [%s]", se.ID) 55 } 56 57 // Error404 overrides the generic 404 error message. 58 func (se ErrServer) Error404(e golangsdk.ErrUnexpectedResponseCode) error { 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 { 66 ErrServer 67 } 68 69 func (e ErrServerNotFound) Error() string { 70 return fmt.Sprintf("I couldn't find server [%s]", e.ID) 71 }