Skip to content

Commit

Permalink
remove unused error
Browse files Browse the repository at this point in the history
  • Loading branch information
octu0 committed Jun 27, 2022
1 parent 66c5b2d commit b588dbd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 49 deletions.
6 changes: 3 additions & 3 deletions bitcask.go
Original file line number Diff line number Diff line change
Expand Up @@ -949,17 +949,17 @@ func Open(path string, funcs ...OptionFunc) (*Bitcask, error) {
opt := newDefaultOption()
for _, fn := range funcs {
if err := fn(opt); err != nil {
return nil, err
return nil, errors.WithStack(err)
}
}

if err := os.MkdirAll(path, opt.DirFileModeBeforeUmask); err != nil {
return nil, err
return nil, errors.WithStack(err)
}

meta, err := loadMetadata(path)
if err != nil {
return nil, &ErrBadMetadata{err}
return nil, errors.WithStack(err)
}

repliEmitter := createRepliEmitter(opt)
Expand Down
46 changes: 0 additions & 46 deletions errors.go
Original file line number Diff line number Diff line change
@@ -1,74 +1,28 @@
package bitcaskdb

import (
"fmt"

"github.com/pkg/errors"
)

var (
// ErrKeyNotFound is the error returned when a key is not found
ErrKeyNotFound = errors.New("error: key not found")

// ErrKeyTooLarge is the error returned for a key that exceeds the
// maximum allowed key size (configured with WithMaxKeySize).
ErrKeyTooLarge = errors.New("error: key too large")

// ErrKeyExpired is the error returned when a key is queried which has
// already expired (due to ttl)
ErrKeyExpired = errors.New("error: key expired")

// ErrEmptyKey is the error returned for a value with an empty key.
ErrEmptyKey = errors.New("error: empty key")

// ErrValueTooLarge is the error returned for a value that exceeds the
// maximum allowed value size (configured with WithMaxValueSize).
ErrValueTooLarge = errors.New("error: value too large")

// ErrDatabaseLocked is the error returned if the database is locked
// (typically opened by another process)
ErrDatabaseLocked = errors.New("error: database locked")

// ErrInvalidRange is the error returned when the range scan is invalid
ErrInvalidRange = errors.New("error: invalid range")

// ErrInvalidVersion is the error returned when the database version is invalid
ErrInvalidVersion = errors.New("error: invalid db version")

// ErrMergeInProgress is the error returned if merge is called when already a merge
// is in progress
ErrMergeInProgress = errors.New("error: merge already in progress")
)

// ErrBadConfig is the error returned on failure to load the database config
type ErrBadConfig struct {
Err error
}

func (e *ErrBadConfig) Is(target error) bool {
if _, ok := target.(*ErrBadConfig); ok {
return true
}
return errors.Is(e.Err, target)
}
func (e *ErrBadConfig) Unwrap() error { return e.Err }
func (e *ErrBadConfig) Error() string {
return fmt.Sprintf("error reading config.json: %s", e.Err)
}

// ErrBadMetadata is the error returned on failure to load the database metadata
type ErrBadMetadata struct {
Err error
}

func (e *ErrBadMetadata) Is(target error) bool {
if _, ok := target.(*ErrBadMetadata); ok {
return true
}
return errors.Is(e.Err, target)
}

func (e *ErrBadMetadata) Unwrap() error { return e.Err }
func (e *ErrBadMetadata) Error() string {
return fmt.Sprintf("error reading meta.json: %s", e.Err)
}

0 comments on commit b588dbd

Please sign in to comment.