github.com/koko1123/flow-go-1@v0.29.6/storage/badger/common.go (about)

     1  package badger
     2  
     3  import (
     4  	"errors"
     5  	"fmt"
     6  
     7  	"github.com/dgraph-io/badger/v3"
     8  
     9  	"github.com/koko1123/flow-go-1/storage"
    10  )
    11  
    12  func handleError(err error, t interface{}) error {
    13  	if err != nil {
    14  		if errors.Is(err, badger.ErrKeyNotFound) {
    15  			return storage.ErrNotFound
    16  		}
    17  
    18  		return fmt.Errorf("could not retrieve %T: %w", t, err)
    19  	}
    20  	return nil
    21  }