Skip to content

Commit

Permalink
Enhance GetBridgeDBInstance: Add Error Handling for LevelDB Initializ…
Browse files Browse the repository at this point in the history
…ation (#1201)

* Add Error Handling for LevelDB Initialization

* Add Error Handling for LevelDB Initialization
  • Loading branch information
vinayak0035 authored Nov 14, 2024
1 parent ec7ac02 commit d90fa7a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions bridge/setu/util/db.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package util

import (
"log"
"sync"

"github.com/syndtr/goleveldb/leveldb"
Expand All @@ -13,9 +14,12 @@ var bridgeDBCloseOnce sync.Once
// GetBridgeDBInstance get sington object for bridge-db
func GetBridgeDBInstance(filePath string) *leveldb.DB {
bridgeDBOnce.Do(func() {
bridgeDB, _ = leveldb.OpenFile(filePath, nil)
var err error
bridgeDB, err = leveldb.OpenFile(filePath, nil)
if err != nil {
log.Fatalln("Error in Bor Opening Database", err.Error())
}
})

return bridgeDB
}

Expand Down

0 comments on commit d90fa7a

Please sign in to comment.