-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
3 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} |