Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrMissingAPI is thrown when the *api.API reference is null. ErrMissingAPI = errors.New("api reference is required for the operation") // ErrDeploymentID is the message returned when a provided cluster id is not of the expected length (32 chars). ErrDeploymentID = errors.New("deployment id should have a length of 32 characters") )
View Source
var ( // ErrTimedOut is returned when the error is context.DeadlineExceeded. ErrTimedOut = errors.New("operation timed out") // ErrMissingElevatedPermissions is returned when the error code is 449. ErrMissingElevatedPermissions = errors.New("the requested operation requires elevated permissions") )
Functions ¶
func NewJSONError ¶ added in v1.1.0
NewJSONError creates a marshaleable error from an error.
func Unwrap ¶
Unwrap unpacks an error message returned from a client API call. It checks for a few cases where the returned API error might not have been properly casted to its error type. It covers the following cases in order:
- error is nil, in which case nil is returned.
- error is a context.DeadlineExceeded error, which equals a timeout.
- error is of type *runtime.APIError, meaning the returned API error wasn't defined in the Swagger spec from which the source code has been generated
- HTTP code is 449, the authenticated user needs to elevate-permissions.
- The type wraps *http.Response, the body is read and tries json.Unmarshal to *models.BasicFailedResponse and each of the BasicFailedReplyElement is then added to an instance ofmultierror.Prefixed and returned.
- The error is unknown, returns "<OperationName> (status <StatusCode)".
- error is a correctly unpacked into BasicFailedReply object which needs to be unpacked from its container struct. If the error cannot be unpacked to a BasicFailedReply, then a stringified json.MarshalIndent error is formed.
Types ¶
Click to show internal directories.
Click to hide internal directories.