style(backend): improve error handling

This commit is contained in:
2025-10-10 01:37:01 +03:00
parent d124229308
commit b774d2b3c9
4 changed files with 115 additions and 85 deletions
@@ -38,7 +38,7 @@ func New(dbURL string) (*pgxpool.Pool, error) {
func transaction(ctx context.Context, db *pgxpool.Pool, handler func(context.Context, pgx.Tx) *domain.DomainError) (domainErr *domain.DomainError) {
tx, err := db.Begin(ctx)
if err != nil {
domainErr = domain.NewUnexpectedError(err)
domainErr = domain.NewErrorUnexpected().Wrap(err)
return
}
domainErr = handler(ctx, tx)
@@ -48,7 +48,7 @@ func transaction(ctx context.Context, db *pgxpool.Pool, handler func(context.Con
}
err = tx.Commit(ctx)
if err != nil {
domainErr = domain.NewUnexpectedError(err)
domainErr = domain.NewErrorUnexpected().Wrap(err)
}
return
}