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 *SubscriptionTypeController) New(c *gin.Context) {
return
}
wm := wc.SubscriptionTypeService.New(c, body)
wm, exception := wc.SubscriptionTypeService.New(c, body)
if exception != nil {
c.JSON(exception.StatusCode, exception)
return
}
c.JSON(200, wm)
}
@@ -58,7 +62,10 @@ GetAll
func (wc *SubscriptionTypeController) GetAll(c *gin.Context) {
embed, _ := c.GetQuery("embed")
wm := wc.SubscriptionTypeService.GetAll(c, embed)
wm, exception := wc.SubscriptionTypeService.GetAll(c, embed)
if exception != nil {
c.JSON(exception.StatusCode, exception)
return
}
c.JSON(200, wm)
}