Skip to content

Commit

Permalink
fix: returns wrong error in transaction (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
lonetrail committed Sep 6, 2024
1 parent 0a29e8d commit 3a46aa3
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions transaction/ent/internal/biz/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,17 @@ func (u *UserUsecase) CreateUser(ctx context.Context, m *User) (int, error) {
err error
id int
)
if e := u.tm.InTx(ctx, func(ctx context.Context) error {
err = u.tm.InTx(ctx, func(ctx context.Context) error {
id, err = u.userRepo.CreateUser(ctx, m)
if err != nil {
return err
}
if _, e := u.cardRepo.CreateCard(ctx, id); err != nil {
return e
if _, err := u.cardRepo.CreateCard(ctx, id); err != nil {
return err
}
return nil
}); e != nil {
})
if err != nil {
return 0, err
}
return id, nil
Expand Down

0 comments on commit 3a46aa3

Please sign in to comment.