added exception messages to controllers

This commit is contained in:
Fran Jurmanović
2022-02-20 10:38:08 +01:00
parent 1b418ec5a2
commit 341647ccd9
18 changed files with 516 additions and 182 deletions

View File

@@ -45,7 +45,11 @@ func (wc *TransactionTypeController) New(c *gin.Context) {
return
}
wm := wc.TransactionTypeService.New(c, body)
wm, exception := wc.TransactionTypeService.New(c, body)
if exception != nil {
c.JSON(exception.StatusCode, exception)
return
}
c.JSON(200, wm)
}
@@ -58,7 +62,11 @@ GetAll
func (wc *TransactionTypeController) GetAll(c *gin.Context) {
embed, _ := c.GetQuery("embed")
wm := wc.TransactionTypeService.GetAll(c, embed)
wm, exception := wc.TransactionTypeService.GetAll(c, embed)
if exception != nil {
c.JSON(exception.StatusCode, exception)
return
}
c.JSON(200, wm)
}