github.com/milvus-io/milvus-sdk-go/v2@v2.4.1/client/errors.go (about)

     1  // Copyright (C) 2019-2021 Zilliz. All rights reserved.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance
     4  // with the License. You may obtain a copy of the License at
     5  //
     6  // http://www.apache.org/licenses/LICENSE-2.0
     7  //
     8  // Unless required by applicable law or agreed to in writing, software distributed under the License
     9  // is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
    10  // or implied. See the License for the specific language governing permissions and limitations under the License.
    11  
    12  package client
    13  
    14  import (
    15  	"fmt"
    16  
    17  	"github.com/cockroachdb/errors"
    18  )
    19  
    20  // ErrServiceFailed indicates error returns from milvus Service
    21  type ErrServiceFailed error
    22  
    23  var (
    24  	//ErrClientNotReady error indicates client not ready
    25  	ErrClientNotReady = errors.New("client not ready")
    26  
    27  	//ErrStatusNil error indicates response has nil status
    28  	ErrStatusNil = errors.New("response status is nil")
    29  
    30  	// ErrFeatureNotSupported error indicates current server does not support this feature
    31  	ErrFeatureNotSupported = errors.New("feature not supported")
    32  )
    33  
    34  // ErrCollectionNotExists indicates the collection with specified collection name does not exist
    35  type ErrCollectionNotExists struct {
    36  	collName string
    37  }
    38  
    39  // Error implement error
    40  func (e ErrCollectionNotExists) Error() string {
    41  	return fmt.Sprintf("collection %s does not exist", e.collName)
    42  }
    43  
    44  // ErrPartitionNotExists indicates the partition of collection does not exist
    45  type ErrPartitionNotExists struct {
    46  	collName     string
    47  	paritionName string
    48  }
    49  
    50  // Error implement error
    51  func (e ErrPartitionNotExists) Error() string {
    52  	return fmt.Sprintf("partition %s of collection %s does not exist", e.paritionName, e.collName)
    53  }
    54  
    55  func collNotExistsErr(collName string) ErrCollectionNotExists {
    56  	return ErrCollectionNotExists{collName: collName}
    57  }
    58  
    59  func partNotExistsErr(collName, partitionName string) ErrPartitionNotExists {
    60  	return ErrPartitionNotExists{collName: collName, paritionName: partitionName}
    61  }