From 6444849ada06ca5af09625e2edf03f62b55d529a Mon Sep 17 00:00:00 2001 From: Tai Groot Date: Sun, 6 Feb 2022 12:33:52 -0800 Subject: [PATCH] move error definition to errors file --- v2/bitcask.go | 3 --- v2/errors.go | 14 ++++++++++---- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/v2/bitcask.go b/v2/bitcask.go index 43e01e1..6392c81 100644 --- a/v2/bitcask.go +++ b/v2/bitcask.go @@ -3,7 +3,6 @@ package bitcask import ( "bytes" "context" - "errors" "fmt" "hash/crc32" "io" @@ -34,8 +33,6 @@ const ( ttlIndexFile = "ttl_index" ) -var ErrContextDeadlineExceeded = errors.New("Context deadline exceeded.") - // Bitcask is a struct that represents a on-disk LSM and WAL data structure // and in-memory hash of key/value pairs as per the Bitcask paper and seen // in the Riak database. diff --git a/v2/errors.go b/v2/errors.go index e465ebc..3ba7b36 100644 --- a/v2/errors.go +++ b/v2/errors.go @@ -35,12 +35,17 @@ var ( // 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 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 is the error returned if merge is called when already + // a merge is in progress ErrMergeInProgress = errors.New("error: merge already in progress") + + // ErrContextDeadlineExceeded occurs when a call to bitcask doesn't finish + // before the caller's context Deadline expires + ErrContextDeadlineExceeded = errors.New("Context deadline exceeded.") ) // ErrBadConfig is the error returned on failure to load the database config @@ -59,7 +64,8 @@ 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 +// ErrBadMetadata is the error returned on failure to load the database +// metadata type ErrBadMetadata struct { Err error }