style(backend): improve error handling
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user