jrperritt | b101323 | 2016-02-10 19:01:53 -0600 | [diff] [blame] | 1 | package gophercloud |
| 2 | |
| 3 | import "fmt" |
| 4 | |
| 5 | // BaseError is an error type that all other error types embed. |
| 6 | type BaseError struct { |
Jon Perritt | 2be387a | 2016-03-31 09:31:58 -0500 | [diff] [blame] | 7 | DefaultErrString string |
| 8 | Info string |
jrperritt | b101323 | 2016-02-10 19:01:53 -0600 | [diff] [blame] | 9 | } |
| 10 | |
Jon Perritt | a33da23 | 2016-03-02 04:43:08 -0600 | [diff] [blame] | 11 | func (e BaseError) Error() string { |
Jon Perritt | 2be387a | 2016-03-31 09:31:58 -0500 | [diff] [blame] | 12 | e.DefaultErrString = "An error occurred while executing a Gophercloud request." |
| 13 | return e.choseErrString() |
| 14 | } |
| 15 | |
| 16 | func (e BaseError) choseErrString() string { |
| 17 | if e.Info != "" { |
| 18 | return e.Info |
| 19 | } |
| 20 | return e.DefaultErrString |
jrperritt | b101323 | 2016-02-10 19:01:53 -0600 | [diff] [blame] | 21 | } |
| 22 | |
Jon Perritt | 256208d | 2016-02-28 23:38:03 -0600 | [diff] [blame] | 23 | // ErrMissingInput is the error when input is required in a particular |
| 24 | // situation but not provided by the user |
| 25 | type ErrMissingInput struct { |
Jon Perritt | a33da23 | 2016-03-02 04:43:08 -0600 | [diff] [blame] | 26 | BaseError |
Jon Perritt | 256208d | 2016-02-28 23:38:03 -0600 | [diff] [blame] | 27 | Argument string |
| 28 | } |
| 29 | |
Jon Perritt | f094fef | 2016-03-07 01:41:59 -0600 | [diff] [blame] | 30 | func (e ErrMissingInput) Error() string { |
Jon Perritt | 2be387a | 2016-03-31 09:31:58 -0500 | [diff] [blame] | 31 | e.DefaultErrString = fmt.Sprintf("Missing input for argument [%s]", e.Argument) |
| 32 | return e.choseErrString() |
Jon Perritt | 256208d | 2016-02-28 23:38:03 -0600 | [diff] [blame] | 33 | } |
| 34 | |
Jon Perritt | f094fef | 2016-03-07 01:41:59 -0600 | [diff] [blame] | 35 | // ErrInvalidInput is an error type used for most non-HTTP Gophercloud errors. |
| 36 | type ErrInvalidInput struct { |
| 37 | ErrMissingInput |
| 38 | Value interface{} |
| 39 | } |
| 40 | |
| 41 | func (e ErrInvalidInput) Error() string { |
Jon Perritt | 2be387a | 2016-03-31 09:31:58 -0500 | [diff] [blame] | 42 | e.DefaultErrString = fmt.Sprintf("Invalid input provided for argument [%s]: [%+v]", e.Argument, e.Value) |
| 43 | return e.choseErrString() |
Jon Perritt | f094fef | 2016-03-07 01:41:59 -0600 | [diff] [blame] | 44 | } |
| 45 | |
jrperritt | b101323 | 2016-02-10 19:01:53 -0600 | [diff] [blame] | 46 | // ErrUnexpectedResponseCode is returned by the Request method when a response code other than |
| 47 | // those listed in OkCodes is encountered. |
| 48 | type ErrUnexpectedResponseCode struct { |
Jon Perritt | a33da23 | 2016-03-02 04:43:08 -0600 | [diff] [blame] | 49 | BaseError |
jrperritt | b101323 | 2016-02-10 19:01:53 -0600 | [diff] [blame] | 50 | URL string |
| 51 | Method string |
| 52 | Expected []int |
| 53 | Actual int |
| 54 | Body []byte |
| 55 | } |
| 56 | |
Jon Perritt | 2be387a | 2016-03-31 09:31:58 -0500 | [diff] [blame] | 57 | func (e ErrUnexpectedResponseCode) Error() string { |
| 58 | e.DefaultErrString = fmt.Sprintf( |
jrperritt | b101323 | 2016-02-10 19:01:53 -0600 | [diff] [blame] | 59 | "Expected HTTP response code %v when accessing [%s %s], but got %d instead\n%s", |
Jon Perritt | 2be387a | 2016-03-31 09:31:58 -0500 | [diff] [blame] | 60 | e.Expected, e.Method, e.URL, e.Actual, e.Body, |
jrperritt | b101323 | 2016-02-10 19:01:53 -0600 | [diff] [blame] | 61 | ) |
Jon Perritt | 2be387a | 2016-03-31 09:31:58 -0500 | [diff] [blame] | 62 | return e.choseErrString() |
jrperritt | b101323 | 2016-02-10 19:01:53 -0600 | [diff] [blame] | 63 | } |
| 64 | |
Jon Perritt | e0f9e4f | 2016-02-21 21:41:03 -0600 | [diff] [blame] | 65 | // ErrDefault400 is the default error type returned on a 400 HTTP response code. |
jrperritt | b101323 | 2016-02-10 19:01:53 -0600 | [diff] [blame] | 66 | type ErrDefault400 struct { |
Jon Perritt | f094fef | 2016-03-07 01:41:59 -0600 | [diff] [blame] | 67 | ErrUnexpectedResponseCode |
jrperritt | b101323 | 2016-02-10 19:01:53 -0600 | [diff] [blame] | 68 | } |
Jon Perritt | e0f9e4f | 2016-02-21 21:41:03 -0600 | [diff] [blame] | 69 | |
| 70 | // ErrDefault401 is the default error type returned on a 401 HTTP response code. |
jrperritt | b101323 | 2016-02-10 19:01:53 -0600 | [diff] [blame] | 71 | type ErrDefault401 struct { |
Jon Perritt | f094fef | 2016-03-07 01:41:59 -0600 | [diff] [blame] | 72 | ErrUnexpectedResponseCode |
jrperritt | b101323 | 2016-02-10 19:01:53 -0600 | [diff] [blame] | 73 | } |
Jon Perritt | e0f9e4f | 2016-02-21 21:41:03 -0600 | [diff] [blame] | 74 | |
| 75 | // ErrDefault404 is the default error type returned on a 404 HTTP response code. |
jrperritt | b101323 | 2016-02-10 19:01:53 -0600 | [diff] [blame] | 76 | type ErrDefault404 struct { |
Jon Perritt | f094fef | 2016-03-07 01:41:59 -0600 | [diff] [blame] | 77 | ErrUnexpectedResponseCode |
jrperritt | b101323 | 2016-02-10 19:01:53 -0600 | [diff] [blame] | 78 | } |
Jon Perritt | e0f9e4f | 2016-02-21 21:41:03 -0600 | [diff] [blame] | 79 | |
| 80 | // ErrDefault405 is the default error type returned on a 405 HTTP response code. |
jrperritt | b101323 | 2016-02-10 19:01:53 -0600 | [diff] [blame] | 81 | type ErrDefault405 struct { |
Jon Perritt | f094fef | 2016-03-07 01:41:59 -0600 | [diff] [blame] | 82 | ErrUnexpectedResponseCode |
jrperritt | b101323 | 2016-02-10 19:01:53 -0600 | [diff] [blame] | 83 | } |
Jon Perritt | e0f9e4f | 2016-02-21 21:41:03 -0600 | [diff] [blame] | 84 | |
| 85 | // ErrDefault408 is the default error type returned on a 408 HTTP response code. |
jrperritt | b101323 | 2016-02-10 19:01:53 -0600 | [diff] [blame] | 86 | type ErrDefault408 struct { |
Jon Perritt | f094fef | 2016-03-07 01:41:59 -0600 | [diff] [blame] | 87 | ErrUnexpectedResponseCode |
jrperritt | b101323 | 2016-02-10 19:01:53 -0600 | [diff] [blame] | 88 | } |
Jon Perritt | e0f9e4f | 2016-02-21 21:41:03 -0600 | [diff] [blame] | 89 | |
| 90 | // ErrDefault429 is the default error type returned on a 429 HTTP response code. |
jrperritt | b101323 | 2016-02-10 19:01:53 -0600 | [diff] [blame] | 91 | type ErrDefault429 struct { |
Jon Perritt | f094fef | 2016-03-07 01:41:59 -0600 | [diff] [blame] | 92 | ErrUnexpectedResponseCode |
jrperritt | b101323 | 2016-02-10 19:01:53 -0600 | [diff] [blame] | 93 | } |
Jon Perritt | e0f9e4f | 2016-02-21 21:41:03 -0600 | [diff] [blame] | 94 | |
| 95 | // ErrDefault500 is the default error type returned on a 500 HTTP response code. |
jrperritt | b101323 | 2016-02-10 19:01:53 -0600 | [diff] [blame] | 96 | type ErrDefault500 struct { |
Jon Perritt | f094fef | 2016-03-07 01:41:59 -0600 | [diff] [blame] | 97 | ErrUnexpectedResponseCode |
jrperritt | b101323 | 2016-02-10 19:01:53 -0600 | [diff] [blame] | 98 | } |
Jon Perritt | e0f9e4f | 2016-02-21 21:41:03 -0600 | [diff] [blame] | 99 | |
| 100 | // ErrDefault503 is the default error type returned on a 503 HTTP response code. |
jrperritt | b101323 | 2016-02-10 19:01:53 -0600 | [diff] [blame] | 101 | type ErrDefault503 struct { |
Jon Perritt | f094fef | 2016-03-07 01:41:59 -0600 | [diff] [blame] | 102 | ErrUnexpectedResponseCode |
jrperritt | b101323 | 2016-02-10 19:01:53 -0600 | [diff] [blame] | 103 | } |
| 104 | |
| 105 | func (e ErrDefault400) Error() string { |
| 106 | return "Invalid request due to incorrect syntax or missing required parameters." |
| 107 | } |
| 108 | func (e ErrDefault401) Error() string { |
| 109 | return "Authentication failed" |
| 110 | } |
| 111 | func (e ErrDefault404) Error() string { |
| 112 | return "Resource not found" |
| 113 | } |
| 114 | func (e ErrDefault405) Error() string { |
| 115 | return "Method not allowed" |
| 116 | } |
| 117 | func (e ErrDefault408) Error() string { |
| 118 | return "The server timed out waiting for the request" |
| 119 | } |
| 120 | func (e ErrDefault429) Error() string { |
Jon Perritt | 256208d | 2016-02-28 23:38:03 -0600 | [diff] [blame] | 121 | return "Too many requests have been sent in a given amount of time. Pause" + |
| 122 | " requests, wait up to one minute, and try again." |
jrperritt | b101323 | 2016-02-10 19:01:53 -0600 | [diff] [blame] | 123 | } |
| 124 | func (e ErrDefault500) Error() string { |
| 125 | return "Internal Server Error" |
| 126 | } |
| 127 | func (e ErrDefault503) Error() string { |
Jon Perritt | 256208d | 2016-02-28 23:38:03 -0600 | [diff] [blame] | 128 | return "The service is currently unable to handle the request due to a temporary" + |
| 129 | " overloading or maintenance. This is a temporary condition. Try again later." |
jrperritt | b101323 | 2016-02-10 19:01:53 -0600 | [diff] [blame] | 130 | } |
| 131 | |
| 132 | // Err400er is the interface resource error types implement to override the error message |
| 133 | // from a 400 error. |
| 134 | type Err400er interface { |
Jon Perritt | f094fef | 2016-03-07 01:41:59 -0600 | [diff] [blame] | 135 | Error400(ErrUnexpectedResponseCode) error |
jrperritt | b101323 | 2016-02-10 19:01:53 -0600 | [diff] [blame] | 136 | } |
| 137 | |
| 138 | // Err401er is the interface resource error types implement to override the error message |
| 139 | // from a 401 error. |
| 140 | type Err401er interface { |
Jon Perritt | f094fef | 2016-03-07 01:41:59 -0600 | [diff] [blame] | 141 | Error401(ErrUnexpectedResponseCode) error |
jrperritt | b101323 | 2016-02-10 19:01:53 -0600 | [diff] [blame] | 142 | } |
| 143 | |
| 144 | // Err404er is the interface resource error types implement to override the error message |
| 145 | // from a 404 error. |
| 146 | type Err404er interface { |
Jon Perritt | f094fef | 2016-03-07 01:41:59 -0600 | [diff] [blame] | 147 | Error404(ErrUnexpectedResponseCode) error |
jrperritt | b101323 | 2016-02-10 19:01:53 -0600 | [diff] [blame] | 148 | } |
| 149 | |
| 150 | // Err405er is the interface resource error types implement to override the error message |
| 151 | // from a 405 error. |
| 152 | type Err405er interface { |
Jon Perritt | f094fef | 2016-03-07 01:41:59 -0600 | [diff] [blame] | 153 | Error405(ErrUnexpectedResponseCode) error |
jrperritt | b101323 | 2016-02-10 19:01:53 -0600 | [diff] [blame] | 154 | } |
| 155 | |
| 156 | // Err408er is the interface resource error types implement to override the error message |
| 157 | // from a 408 error. |
| 158 | type Err408er interface { |
Jon Perritt | f094fef | 2016-03-07 01:41:59 -0600 | [diff] [blame] | 159 | Error408(ErrUnexpectedResponseCode) error |
jrperritt | b101323 | 2016-02-10 19:01:53 -0600 | [diff] [blame] | 160 | } |
| 161 | |
| 162 | // Err429er is the interface resource error types implement to override the error message |
| 163 | // from a 429 error. |
| 164 | type Err429er interface { |
Jon Perritt | f094fef | 2016-03-07 01:41:59 -0600 | [diff] [blame] | 165 | Error429(ErrUnexpectedResponseCode) error |
jrperritt | b101323 | 2016-02-10 19:01:53 -0600 | [diff] [blame] | 166 | } |
| 167 | |
| 168 | // Err500er is the interface resource error types implement to override the error message |
| 169 | // from a 500 error. |
| 170 | type Err500er interface { |
Jon Perritt | f094fef | 2016-03-07 01:41:59 -0600 | [diff] [blame] | 171 | Error500(ErrUnexpectedResponseCode) error |
jrperritt | b101323 | 2016-02-10 19:01:53 -0600 | [diff] [blame] | 172 | } |
| 173 | |
| 174 | // Err503er is the interface resource error types implement to override the error message |
| 175 | // from a 503 error. |
| 176 | type Err503er interface { |
Jon Perritt | f094fef | 2016-03-07 01:41:59 -0600 | [diff] [blame] | 177 | Error503(ErrUnexpectedResponseCode) error |
jrperritt | b101323 | 2016-02-10 19:01:53 -0600 | [diff] [blame] | 178 | } |
| 179 | |
Jon Perritt | e0f9e4f | 2016-02-21 21:41:03 -0600 | [diff] [blame] | 180 | // ErrTimeOut is the error type returned when an operations times out. |
jrperritt | b101323 | 2016-02-10 19:01:53 -0600 | [diff] [blame] | 181 | type ErrTimeOut struct { |
Jon Perritt | a33da23 | 2016-03-02 04:43:08 -0600 | [diff] [blame] | 182 | BaseError |
jrperritt | b101323 | 2016-02-10 19:01:53 -0600 | [diff] [blame] | 183 | } |
| 184 | |
Jon Perritt | f094fef | 2016-03-07 01:41:59 -0600 | [diff] [blame] | 185 | func (e ErrTimeOut) Error() string { |
Jon Perritt | 2be387a | 2016-03-31 09:31:58 -0500 | [diff] [blame] | 186 | e.DefaultErrString = "A time out occurred" |
| 187 | return e.choseErrString() |
jrperritt | b101323 | 2016-02-10 19:01:53 -0600 | [diff] [blame] | 188 | } |
| 189 | |
Jon Perritt | e0f9e4f | 2016-02-21 21:41:03 -0600 | [diff] [blame] | 190 | // ErrUnableToReauthenticate is the error type returned when reauthentication fails. |
jrperritt | b101323 | 2016-02-10 19:01:53 -0600 | [diff] [blame] | 191 | type ErrUnableToReauthenticate struct { |
Jon Perritt | a33da23 | 2016-03-02 04:43:08 -0600 | [diff] [blame] | 192 | BaseError |
Jon Perritt | f094fef | 2016-03-07 01:41:59 -0600 | [diff] [blame] | 193 | ErrOriginal error |
jrperritt | b101323 | 2016-02-10 19:01:53 -0600 | [diff] [blame] | 194 | } |
| 195 | |
Jon Perritt | f094fef | 2016-03-07 01:41:59 -0600 | [diff] [blame] | 196 | func (e ErrUnableToReauthenticate) Error() string { |
Jon Perritt | 2be387a | 2016-03-31 09:31:58 -0500 | [diff] [blame] | 197 | e.DefaultErrString = fmt.Sprintf("Unable to re-authenticate: %s", e.ErrOriginal) |
| 198 | return e.choseErrString() |
jrperritt | b101323 | 2016-02-10 19:01:53 -0600 | [diff] [blame] | 199 | } |
| 200 | |
Jon Perritt | e0f9e4f | 2016-02-21 21:41:03 -0600 | [diff] [blame] | 201 | // ErrErrorAfterReauthentication is the error type returned when reauthentication |
| 202 | // succeeds, but an error occurs afterword (usually an HTTP error). |
jrperritt | b101323 | 2016-02-10 19:01:53 -0600 | [diff] [blame] | 203 | type ErrErrorAfterReauthentication struct { |
Jon Perritt | a33da23 | 2016-03-02 04:43:08 -0600 | [diff] [blame] | 204 | BaseError |
Jon Perritt | f094fef | 2016-03-07 01:41:59 -0600 | [diff] [blame] | 205 | ErrOriginal error |
jrperritt | b101323 | 2016-02-10 19:01:53 -0600 | [diff] [blame] | 206 | } |
| 207 | |
Jon Perritt | f094fef | 2016-03-07 01:41:59 -0600 | [diff] [blame] | 208 | func (e ErrErrorAfterReauthentication) Error() string { |
Jon Perritt | 2be387a | 2016-03-31 09:31:58 -0500 | [diff] [blame] | 209 | e.DefaultErrString = fmt.Sprintf("Successfully re-authenticated, but got error executing request: %s", e.ErrOriginal) |
| 210 | return e.choseErrString() |
jrperritt | b101323 | 2016-02-10 19:01:53 -0600 | [diff] [blame] | 211 | } |
| 212 | |
| 213 | // ErrServiceNotFound is returned when no service in a service catalog matches |
| 214 | // the provided EndpointOpts. This is generally returned by provider service |
| 215 | // factory methods like "NewComputeV2()" and can mean that a service is not |
| 216 | // enabled for your account. |
| 217 | type ErrServiceNotFound struct { |
Jon Perritt | a33da23 | 2016-03-02 04:43:08 -0600 | [diff] [blame] | 218 | BaseError |
jrperritt | b101323 | 2016-02-10 19:01:53 -0600 | [diff] [blame] | 219 | } |
| 220 | |
Jon Perritt | f094fef | 2016-03-07 01:41:59 -0600 | [diff] [blame] | 221 | func (e ErrServiceNotFound) Error() string { |
Jon Perritt | 2be387a | 2016-03-31 09:31:58 -0500 | [diff] [blame] | 222 | e.DefaultErrString = "No suitable service could be found in the service catalog." |
| 223 | return e.choseErrString() |
jrperritt | b101323 | 2016-02-10 19:01:53 -0600 | [diff] [blame] | 224 | } |
| 225 | |
| 226 | // ErrEndpointNotFound is returned when no available endpoints match the |
| 227 | // provided EndpointOpts. This is also generally returned by provider service |
| 228 | // factory methods, and usually indicates that a region was specified |
| 229 | // incorrectly. |
| 230 | type ErrEndpointNotFound struct { |
Jon Perritt | a33da23 | 2016-03-02 04:43:08 -0600 | [diff] [blame] | 231 | BaseError |
jrperritt | b101323 | 2016-02-10 19:01:53 -0600 | [diff] [blame] | 232 | } |
| 233 | |
Jon Perritt | f094fef | 2016-03-07 01:41:59 -0600 | [diff] [blame] | 234 | func (e ErrEndpointNotFound) Error() string { |
Jon Perritt | 2be387a | 2016-03-31 09:31:58 -0500 | [diff] [blame] | 235 | e.DefaultErrString = "No suitable endpoint could be found in the service catalog." |
| 236 | return e.choseErrString() |
jrperritt | b101323 | 2016-02-10 19:01:53 -0600 | [diff] [blame] | 237 | } |
Jon Perritt | 256208d | 2016-02-28 23:38:03 -0600 | [diff] [blame] | 238 | |
| 239 | // ErrResourceNotFound is the error when trying to retrieve a resource's |
| 240 | // ID by name and the resource doesn't exist. |
| 241 | type ErrResourceNotFound struct { |
Jon Perritt | a33da23 | 2016-03-02 04:43:08 -0600 | [diff] [blame] | 242 | BaseError |
Jon Perritt | f094fef | 2016-03-07 01:41:59 -0600 | [diff] [blame] | 243 | Name string |
Jon Perritt | 256208d | 2016-02-28 23:38:03 -0600 | [diff] [blame] | 244 | ResourceType string |
| 245 | } |
| 246 | |
Jon Perritt | f094fef | 2016-03-07 01:41:59 -0600 | [diff] [blame] | 247 | func (e ErrResourceNotFound) Error() string { |
Jon Perritt | 2be387a | 2016-03-31 09:31:58 -0500 | [diff] [blame] | 248 | e.DefaultErrString = fmt.Sprintf("Unable to find %s with name %s", e.ResourceType, e.Name) |
| 249 | return e.choseErrString() |
Jon Perritt | 256208d | 2016-02-28 23:38:03 -0600 | [diff] [blame] | 250 | } |
| 251 | |
| 252 | // ErrMultipleResourcesFound is the error when trying to retrieve a resource's |
| 253 | // ID by name and multiple resources have the user-provided name. |
| 254 | type ErrMultipleResourcesFound struct { |
Jon Perritt | a33da23 | 2016-03-02 04:43:08 -0600 | [diff] [blame] | 255 | BaseError |
Jon Perritt | 256208d | 2016-02-28 23:38:03 -0600 | [diff] [blame] | 256 | Name string |
| 257 | Count int |
| 258 | ResourceType string |
| 259 | } |
| 260 | |
Jon Perritt | f094fef | 2016-03-07 01:41:59 -0600 | [diff] [blame] | 261 | func (e ErrMultipleResourcesFound) Error() string { |
Jon Perritt | 2be387a | 2016-03-31 09:31:58 -0500 | [diff] [blame] | 262 | e.DefaultErrString = fmt.Sprintf("Found %d %ss matching %s", e.Count, e.ResourceType, e.Name) |
| 263 | return e.choseErrString() |
Jon Perritt | 256208d | 2016-02-28 23:38:03 -0600 | [diff] [blame] | 264 | } |
Jon Perritt | 8025197 | 2016-03-09 00:32:30 -0600 | [diff] [blame] | 265 | |
| 266 | // ErrUnexpectedType is the error when an unexpected type is encountered |
| 267 | type ErrUnexpectedType struct { |
| 268 | BaseError |
| 269 | Expected string |
| 270 | Actual string |
| 271 | } |
| 272 | |
| 273 | func (e ErrUnexpectedType) Error() string { |
Jon Perritt | 2be387a | 2016-03-31 09:31:58 -0500 | [diff] [blame] | 274 | e.DefaultErrString = fmt.Sprintf("Expected %s but got %s", e.Expected, e.Actual) |
| 275 | return e.choseErrString() |
Jon Perritt | 8025197 | 2016-03-09 00:32:30 -0600 | [diff] [blame] | 276 | } |
jrperritt | 0bc5578 | 2016-07-27 13:50:14 -0500 | [diff] [blame] | 277 | |
| 278 | func unacceptedAttributeErr(attribute string) string { |
| 279 | return fmt.Sprintf("The base Identity V3 API does not accept authentication by %s", attribute) |
| 280 | } |
| 281 | |
| 282 | func redundantWithTokenErr(attribute string) string { |
| 283 | return fmt.Sprintf("%s may not be provided when authenticating with a TokenID", attribute) |
| 284 | } |
| 285 | |
| 286 | func redundantWithUserID(attribute string) string { |
| 287 | return fmt.Sprintf("%s may not be provided when authenticating with a UserID", attribute) |
| 288 | } |
| 289 | |
| 290 | // ErrAPIKeyProvided indicates that an APIKey was provided but can't be used. |
| 291 | type ErrAPIKeyProvided struct{ BaseError } |
| 292 | |
| 293 | func (e ErrAPIKeyProvided) Error() string { |
| 294 | return unacceptedAttributeErr("APIKey") |
| 295 | } |
| 296 | |
| 297 | // ErrTenantIDProvided indicates that a TenantID was provided but can't be used. |
| 298 | type ErrTenantIDProvided struct{ BaseError } |
| 299 | |
| 300 | func (e ErrTenantIDProvided) Error() string { |
| 301 | return unacceptedAttributeErr("TenantID") |
| 302 | } |
| 303 | |
| 304 | // ErrTenantNameProvided indicates that a TenantName was provided but can't be used. |
| 305 | type ErrTenantNameProvided struct{ BaseError } |
| 306 | |
| 307 | func (e ErrTenantNameProvided) Error() string { |
| 308 | return unacceptedAttributeErr("TenantName") |
| 309 | } |
| 310 | |
| 311 | // ErrUsernameWithToken indicates that a Username was provided, but token authentication is being used instead. |
| 312 | type ErrUsernameWithToken struct{ BaseError } |
| 313 | |
| 314 | func (e ErrUsernameWithToken) Error() string { |
| 315 | return redundantWithTokenErr("Username") |
| 316 | } |
| 317 | |
| 318 | // ErrUserIDWithToken indicates that a UserID was provided, but token authentication is being used instead. |
| 319 | type ErrUserIDWithToken struct{ BaseError } |
| 320 | |
| 321 | func (e ErrUserIDWithToken) Error() string { |
| 322 | return redundantWithTokenErr("UserID") |
| 323 | } |
| 324 | |
| 325 | // ErrDomainIDWithToken indicates that a DomainID was provided, but token authentication is being used instead. |
| 326 | type ErrDomainIDWithToken struct{ BaseError } |
| 327 | |
| 328 | func (e ErrDomainIDWithToken) Error() string { |
| 329 | return redundantWithTokenErr("DomainID") |
| 330 | } |
| 331 | |
| 332 | // ErrDomainNameWithToken indicates that a DomainName was provided, but token authentication is being used instead.s |
| 333 | type ErrDomainNameWithToken struct{ BaseError } |
| 334 | |
| 335 | func (e ErrDomainNameWithToken) Error() string { |
| 336 | return redundantWithTokenErr("DomainName") |
| 337 | } |
| 338 | |
| 339 | // ErrUsernameOrUserID indicates that neither username nor userID are specified, or both are at once. |
| 340 | type ErrUsernameOrUserID struct{ BaseError } |
| 341 | |
| 342 | func (e ErrUsernameOrUserID) Error() string { |
| 343 | return "Exactly one of Username and UserID must be provided for password authentication" |
| 344 | } |
| 345 | |
| 346 | // ErrDomainIDWithUserID indicates that a DomainID was provided, but unnecessary because a UserID is being used. |
| 347 | type ErrDomainIDWithUserID struct{ BaseError } |
| 348 | |
| 349 | func (e ErrDomainIDWithUserID) Error() string { |
| 350 | return redundantWithUserID("DomainID") |
| 351 | } |
| 352 | |
| 353 | // ErrDomainNameWithUserID indicates that a DomainName was provided, but unnecessary because a UserID is being used. |
| 354 | type ErrDomainNameWithUserID struct{ BaseError } |
| 355 | |
| 356 | func (e ErrDomainNameWithUserID) Error() string { |
| 357 | return redundantWithUserID("DomainName") |
| 358 | } |
| 359 | |
| 360 | // ErrDomainIDOrDomainName indicates that a username was provided, but no domain to scope it. |
| 361 | // It may also indicate that both a DomainID and a DomainName were provided at once. |
| 362 | type ErrDomainIDOrDomainName struct{ BaseError } |
| 363 | |
| 364 | func (e ErrDomainIDOrDomainName) Error() string { |
| 365 | return "You must provide exactly one of DomainID or DomainName to authenticate by Username" |
| 366 | } |
| 367 | |
| 368 | // ErrMissingPassword indicates that no password was provided and no token is available. |
| 369 | type ErrMissingPassword struct{ BaseError } |
| 370 | |
| 371 | func (e ErrMissingPassword) Error() string { |
| 372 | return "You must provide a password to authenticate" |
| 373 | } |
| 374 | |
| 375 | // ErrScopeDomainIDOrDomainName indicates that a domain ID or Name was required in a Scope, but not present. |
| 376 | type ErrScopeDomainIDOrDomainName struct{ BaseError } |
| 377 | |
| 378 | func (e ErrScopeDomainIDOrDomainName) Error() string { |
| 379 | return "You must provide exactly one of DomainID or DomainName in a Scope with ProjectName" |
| 380 | } |
| 381 | |
| 382 | // ErrScopeProjectIDOrProjectName indicates that both a ProjectID and a ProjectName were provided in a Scope. |
| 383 | type ErrScopeProjectIDOrProjectName struct{ BaseError } |
| 384 | |
| 385 | func (e ErrScopeProjectIDOrProjectName) Error() string { |
| 386 | return "You must provide at most one of ProjectID or ProjectName in a Scope" |
| 387 | } |
| 388 | |
| 389 | // ErrScopeProjectIDAlone indicates that a ProjectID was provided with other constraints in a Scope. |
| 390 | type ErrScopeProjectIDAlone struct{ BaseError } |
| 391 | |
| 392 | func (e ErrScopeProjectIDAlone) Error() string { |
| 393 | return "ProjectID must be supplied alone in a Scope" |
| 394 | } |
| 395 | |
| 396 | // ErrScopeDomainName indicates that a DomainName was provided alone in a Scope. |
| 397 | type ErrScopeDomainName struct{ BaseError } |
| 398 | |
| 399 | func (e ErrScopeDomainName) Error() string { |
| 400 | return "DomainName must be supplied with a ProjectName or ProjectID in a Scope" |
| 401 | } |
| 402 | |
| 403 | // ErrScopeEmpty indicates that no credentials were provided in a Scope. |
| 404 | type ErrScopeEmpty struct{ BaseError } |
| 405 | |
| 406 | func (e ErrScopeEmpty) Error() string { |
| 407 | return "You must provide either a Project or Domain in a Scope" |
| 408 | } |