Skip to content

Commit 3a46aa3

Browse files
author
lonetrail
authored
fix: returns wrong error in transaction (#45)
1 parent 0a29e8d commit 3a46aa3

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

transaction/ent/internal/biz/transaction.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,17 @@ func (u *UserUsecase) CreateUser(ctx context.Context, m *User) (int, error) {
3434
err error
3535
id int
3636
)
37-
if e := u.tm.InTx(ctx, func(ctx context.Context) error {
37+
err = u.tm.InTx(ctx, func(ctx context.Context) error {
3838
id, err = u.userRepo.CreateUser(ctx, m)
3939
if err != nil {
4040
return err
4141
}
42-
if _, e := u.cardRepo.CreateCard(ctx, id); err != nil {
43-
return e
42+
if _, err := u.cardRepo.CreateCard(ctx, id); err != nil {
43+
return err
4444
}
4545
return nil
46-
}); e != nil {
46+
})
47+
if err != nil {
4748
return 0, err
4849
}
4950
return id, nil

0 commit comments

Comments
 (0)