NewPGStore should not ignore errors
This commit is contained in:
10
pgstore.go
10
pgstore.go
@@ -33,11 +33,11 @@ type Session struct {
|
||||
|
||||
// NewPGStore creates a new PGStore instance and a new database/sql pool.
|
||||
// This will also create in the database the schema needed by pgstore.
|
||||
func NewPGStore(dbURL string, keyPairs ...[]byte) *PGStore {
|
||||
func NewPGStore(dbURL string, keyPairs ...[]byte) (*PGStore, error) {
|
||||
db, err := sql.Open("postgres", dbURL)
|
||||
if err != nil {
|
||||
// Ignore and return nil
|
||||
return nil
|
||||
return nil, err
|
||||
}
|
||||
return NewPGStoreFromPool(db, keyPairs...)
|
||||
}
|
||||
@@ -45,7 +45,7 @@ func NewPGStore(dbURL string, keyPairs ...[]byte) *PGStore {
|
||||
// NewPGStoreFromPool creates a new PGStore instance from an existing
|
||||
// database/sql pool.
|
||||
// This will also create in the database the schema needed by pgstore.
|
||||
func NewPGStoreFromPool(db *sql.DB, keyPairs ...[]byte) *PGStore {
|
||||
func NewPGStoreFromPool(db *sql.DB, keyPairs ...[]byte) (*PGStore, error) {
|
||||
dbmap := &gorp.DbMap{Db: db, Dialect: gorp.PostgresDialect{}}
|
||||
|
||||
dbStore := &PGStore{
|
||||
@@ -63,10 +63,10 @@ func NewPGStoreFromPool(db *sql.DB, keyPairs ...[]byte) *PGStore {
|
||||
|
||||
if err != nil {
|
||||
// Ignore and return nil
|
||||
return nil
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return dbStore
|
||||
return dbStore, nil
|
||||
}
|
||||
|
||||
// Close closes the database connection
|
||||
|
Reference in New Issue
Block a user