fix error handling

This commit is contained in:
chrislu 2022-10-12 00:03:14 -07:00
parent 8aec786a6d
commit dff85e9c71

View file

@ -63,9 +63,11 @@ func (store *SqliteStore) initialize(dbFile, createTable, upsertQuery string) (e
var dbErr error
store.DB, dbErr = sql.Open("sqlite", dbFile)
if dbErr != nil {
store.DB.Close()
store.DB = nil
return fmt.Errorf("can not connect to %s error:%v", dbFile, err)
if store.DB != nil {
store.DB.Close()
store.DB = nil
}
return fmt.Errorf("can not connect to %s error:%v", dbFile, dbErr)
}
if err = store.DB.Ping(); err != nil {