Skip to content

Commit d2f4472

Browse files
authored
Merge pull request #42 from mf-sakura/fix/db-answer
Add error handling of db commit
2 parents 4306ddc + 8b5fc00 commit d2f4472

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

db/cli/interfaces/controllers/user_controller.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,5 @@ func (controller *UserController) Update(id string, firstName string, lastName s
5555
if err != nil {
5656
return
5757
}
58-
tx.Commit()
59-
60-
return
58+
return tx.Commit()
6159
}

test/api/interfaces/controllers/user_controller.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ func (controller *UserController) Create(c echo.Context) (err error) {
4242
return
4343
}
4444
user.ID = id
45-
tx.Commit()
45+
if err := tx.Commit(); err != nil {
46+
return err
47+
}
4648
return c.JSON(http.StatusCreated, &user)
4749
}
4850

0 commit comments

Comments
 (0)