func parseAwsError()

in internal/signer/signer.go [117:138]


func parseAwsError(err error) *plugin.Error {
	var apiError smithy.APIError
	if errors.As(err, &apiError) {
		var re *http.ResponseError
		errMsgSuffix := ""
		if errors.As(err, &re) {
			errMsgSuffix = fmt.Sprintf(" RequestID: %s.", re.ServiceRequestID())
		}
		errMsg := fmt.Sprintf("Failed to call AWSSigner. Error: %s.%s", apiError.ErrorMessage(), errMsgSuffix)
		switch apiError.ErrorCode() {
		case "NotFoundException", "ResourceNotFoundException", "ValidationException", "BadRequestException":
			return plugin.NewValidationError(errMsg)
		case "ThrottlingException":
			return plugin.NewError(plugin.ErrorCodeThrottled, errMsg)
		case "AccessDeniedException":
			return plugin.NewError(plugin.ErrorCodeAccessDenied, errMsg)
		default:
			return plugin.NewGenericError(errMsg)
		}
	}
	return plugin.NewGenericError(err.Error())
}