aboutsummaryrefslogtreecommitdiffstats
path: root/internal/repositories
diff options
context:
space:
mode:
authorEugene Triguba <eugenetriguba@gmail.com>2024-01-28 19:57:15 -0500
committerEugene Triguba <eugenetriguba@gmail.com>2024-01-28 19:57:15 -0500
commitfb84192eef75c909d031aa867d407f1b7797e9db (patch)
tree0badb974c62c4fb180d695378c2e9d7f88eaf4df /internal/repositories
parentWrap db repo and console errs to give better errors (diff)
downloadcli-fb84192eef75c909d031aa867d407f1b7797e9db.zip
Add more wrapped errors
Diffstat (limited to 'internal/repositories')
-rw-r--r--internal/repositories/migration_db_repo.go16
1 files changed, 13 insertions, 3 deletions
diff --git a/internal/repositories/migration_db_repo.go b/internal/repositories/migration_db_repo.go
index 93b9c73..b9e2d78 100644
--- a/internal/repositories/migration_db_repo.go
+++ b/internal/repositories/migration_db_repo.go
@@ -25,7 +25,10 @@ func NewMigrationDBRepo(db *sql.DB) (*MigrationDBRepo, error) {
);
`)
if err != nil {
- return nil, err
+ return nil, fmt.Errorf(
+ "unable to create bolt_migrations database table: %w",
+ err,
+ )
}
return &MigrationDBRepo{db: db}, nil
@@ -38,7 +41,11 @@ func NewMigrationDBRepo(db *sql.DB) (*MigrationDBRepo, error) {
func (mr *MigrationDBRepo) List() (map[string]*models.Migration, error) {
rows, err := mr.db.Query(`SELECT version FROM bolt_migrations;`)
if err != nil {
- return nil, err
+ return nil, fmt.Errorf(
+ "unable to execute query to select versions from "+
+ "bolt_migrations database table: %w",
+ err,
+ )
}
defer rows.Close()
@@ -47,7 +54,10 @@ func (mr *MigrationDBRepo) List() (map[string]*models.Migration, error) {
var version string
err := rows.Scan(&version)
if err != nil {
- return nil, err
+ return nil, fmt.Errorf(
+ "unable to scan version row from applied migrations: %w",
+ err,
+ )
}
trimmedVersion := strings.TrimSpace(version)
migrations[trimmedVersion] = &models.Migration{