diff options
| author | Eugene Triguba <eugenetriguba@gmail.com> | 2024-01-28 19:57:15 -0500 |
|---|---|---|
| committer | Eugene Triguba <eugenetriguba@gmail.com> | 2024-01-28 19:57:15 -0500 |
| commit | fb84192eef75c909d031aa867d407f1b7797e9db (patch) | |
| tree | 0badb974c62c4fb180d695378c2e9d7f88eaf4df /internal/storage | |
| parent | Wrap db repo and console errs to give better errors (diff) | |
| download | cli-fb84192eef75c909d031aa867d407f1b7797e9db.zip | |
Add more wrapped errors
Diffstat (limited to 'internal/storage')
| -rw-r--r-- | internal/storage/db.go | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/internal/storage/db.go b/internal/storage/db.go index 9032dc3..e329e71 100644 --- a/internal/storage/db.go +++ b/internal/storage/db.go @@ -15,16 +15,15 @@ import ( func DBConnect(driver string, connectionParams string) (*sql.DB, error) { db, err := sql.Open(driver, connectionParams) if err != nil { - return nil, err + return nil, fmt.Errorf("invalid database connection parameters: %w", err) } - // Note: `sql.Open` only validates the connection string we provided - // it is sane. It doesn't actually open up a connection to the database. - // For that, we ping the database to ensure the connection string is fully - // valid. + // Note: `sql.Open` only validates the connection string we provided is sane. + // It doesn't actually open up a connection to the database. For that, we ping + // the database to ensure the connection string is fully valid. err = db.Ping() if err != nil { - return nil, err + return nil, fmt.Errorf("unable to ping database: %w", err) } return db, nil |