优化KV存储数据表关闭后的错误提示

This commit is contained in:
刘祥超
2024-04-07 14:55:12 +08:00
parent 1fe15d4e3c
commit 8d72e5fdd1
5 changed files with 70 additions and 2 deletions

View File

@@ -4,12 +4,14 @@ package kvstore
import (
"errors"
"fmt"
"github.com/cockroachdb/pebble"
)
var ErrTableNotFound = errors.New("table not found")
var ErrKeyTooLong = errors.New("too long key")
var ErrSkip= errors.New("skip") // skip count in iterator
var ErrSkip = errors.New("skip") // skip count in iterator
var ErrTableClosed = errors.New("table closed")
func IsNotFound(err error) bool {
return err != nil && errors.Is(err, pebble.ErrNotFound)
@@ -22,3 +24,7 @@ func IsSkipError(err error) bool {
func Skip() (bool, error) {
return true, ErrSkip
}
func NewTableClosedErr(tableName string) error {
return fmt.Errorf("table '"+tableName+"' closed: %w", ErrTableClosed)
}