github.com/cilium/statedb@v0.3.2/errors.go (about)

     1  // SPDX-License-Identifier: Apache-2.0
     2  // Copyright Authors of Cilium
     3  
     4  package statedb
     5  
     6  import (
     7  	"errors"
     8  	"fmt"
     9  )
    10  
    11  var (
    12  	// ErrDuplicateTable indicates that StateDB has been provided with two or more table definitions
    13  	// that share the same table name.
    14  	ErrDuplicateTable = errors.New("table already exists")
    15  
    16  	// ErrTableNotRegistered indicates that a user tries to write to a table that has not been
    17  	// registered with this StateDB instance.
    18  	ErrTableNotRegistered = errors.New("table not registered")
    19  
    20  	// ErrPrimaryIndexNotUnique indicates that the primary index for the table is not marked unique.
    21  	ErrPrimaryIndexNotUnique = errors.New("primary index not unique")
    22  
    23  	// ErrDuplicateIndex indicates that the table has two or more indexers that share the same name.
    24  	ErrDuplicateIndex = errors.New("index name already in use")
    25  
    26  	// ErrReservedPrefix indicates that the index name is using the reserved prefix and should
    27  	// be renamed.
    28  	ErrReservedPrefix = errors.New("index name uses reserved prefix '" + reservedIndexPrefix + "'")
    29  
    30  	// ErrTransactionClosed indicates that a write operation is performed using a transaction
    31  	// that has already been committed or aborted.
    32  	ErrTransactionClosed = errors.New("transaction is closed")
    33  
    34  	// ErrTableNotLockedForWriting indicates that a write operation is performed against a
    35  	// table that was not locked for writing, e.g. target table not given as argument to
    36  	// WriteTxn().
    37  	ErrTableNotLockedForWriting = errors.New("not locked for writing")
    38  
    39  	// ErrRevisionNotEqual indicates that the CompareAndSwap or CompareAndDelete failed due to
    40  	// the object having a mismatching revision, e.g. it had been changed since the object
    41  	// was last read.
    42  	ErrRevisionNotEqual = errors.New("revision not equal")
    43  
    44  	// ErrObjectNotFound indicates that the object was not found when the operation required
    45  	// it to exists. This error is not returned by Insert or Delete, but may be returned by
    46  	// CompareAndSwap or CompareAndDelete.
    47  	ErrObjectNotFound = errors.New("object not found")
    48  )
    49  
    50  // tableError wraps an error with the table name.
    51  func tableError(tableName string, err error) error {
    52  	return fmt.Errorf("table %q: %w", tableName, err)
    53  }