Skip to content

Commit 14606c2

Browse files
committed
logging changes
1 parent f4cf7b5 commit 14606c2

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/db/dblevel/client.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ import (
66
"bytes"
77
"encoding/binary"
88
"encoding/hex"
9+
"errors"
10+
911
"github.com/syndtr/goleveldb/leveldb"
1012
"github.com/syndtr/goleveldb/leveldb/util"
11-
"log"
1213
)
1314

1415
// todo change to `var NoEntryErr = errors.new("[no entry found]")`
@@ -93,15 +94,16 @@ func insertBatch(db *leveldb.DB, pairs []types.Pair) error {
9394
func retrieveByBlockHash(db *leveldb.DB, blockHash string, pair types.Pair) error {
9495
blockHashBytes, err := hex.DecodeString(blockHash)
9596
if err != nil {
96-
log.Println(err)
97+
common.ErrorLogger.Println(err)
9798
return err
9899
}
99100

100101
data, err := db.Get(blockHashBytes, nil)
101-
if err != nil && err.Error() != "leveldb: not found" { // todo this error probably exists as var/type somewhere
102+
if err != nil && !errors.Is(err, NoEntryErr{}) { // todo this error probably exists as var/type somewhere
102103
common.ErrorLogger.Println(err)
103104
return err
104-
} else if err != nil && err.Error() == "leveldb: not found" { // todo this error probably exists as var/type somewhere
105+
} else if err != nil && errors.Is(err, NoEntryErr{}) { // todo this error probably exists as var/type somewhere
106+
// todo we don't need separate patterns if just return the errors anyways? or maybe just to avoid unnecessary logging
105107
return NoEntryErr{}
106108
}
107109
if len(data) == 0 {

0 commit comments

Comments
 (0)