Skip to content

Commit

Permalink
Error handle in Opening Bridge DB
Browse files Browse the repository at this point in the history
  • Loading branch information
vinayak0035 committed Oct 25, 2024
1 parent 8d549d1 commit 612c15b
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions bridge/setu/util/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,17 @@ var bridgeDBOnce sync.Once
var bridgeDBCloseOnce sync.Once

// GetBridgeDBInstance get sington object for bridge-db
func GetBridgeDBInstance(filePath string) *leveldb.DB {
func GetBridgeDBInstance(filePath string) (*leveldb.DB, error) {
var err error
bridgeDBOnce.Do(func() {
bridgeDB, _ = leveldb.OpenFile(filePath, nil)
bridgeDB, err = leveldb.OpenFile(filePath, nil)
})

return bridgeDB
if err != nil {
// Return nil and the error
return nil, err
}
// Return the database instance
return bridgeDB, nil
}

// CloseBridgeDBInstance closes bridge-db instance
Expand Down

0 comments on commit 612c15b

Please sign in to comment.