v0.0.370 improve sq errors
All checks were successful
Build Docker and Deploy / Run goext test-suite (push) Successful in 1m36s

This commit is contained in:
2024-01-13 14:10:25 +01:00
parent aae8a706e9
commit be24f7a190
4 changed files with 18 additions and 8 deletions

View File

@@ -4,6 +4,7 @@ import (
"context"
"database/sql"
"github.com/jmoiron/sqlx"
"gogs.mikescher.com/BlackForestBytes/goext/exerr"
"gogs.mikescher.com/BlackForestBytes/goext/langext"
"sync"
)
@@ -56,7 +57,7 @@ func (db *database) Exec(ctx context.Context, sqlstr string, prep PP) (sql.Resul
}
if err != nil {
return nil, err
return nil, exerr.Wrap(err, "Failed to [exec] sql statement").Str("original_sql", origsql).Str("sql", sqlstr).Any("sql_params", prep).Build()
}
return res, nil
}
@@ -77,7 +78,7 @@ func (db *database) Query(ctx context.Context, sqlstr string, prep PP) (*sqlx.Ro
}
if err != nil {
return nil, err
return nil, exerr.Wrap(err, "Failed to [query] sql statement").Str("original_sql", origsql).Str("sql", sqlstr).Any("sql_params", prep).Build()
}
return rows, nil
}
@@ -97,7 +98,7 @@ func (db *database) Ping(ctx context.Context) error {
}
if err != nil {
return err
return exerr.Wrap(err, "Failed to [ping] sql database").Build()
}
return nil
}
@@ -117,7 +118,7 @@ func (db *database) BeginTransaction(ctx context.Context, iso sql.IsolationLevel
xtx, err := db.db.BeginTxx(ctx, &sql.TxOptions{Isolation: iso})
if err != nil {
return nil, err
return nil, exerr.Wrap(err, "Failed to start sql transaction").Build()
}
for _, v := range db.lstr {