Skip to content

Commit

Permalink
Fixed error handling for projects controllers
Browse files Browse the repository at this point in the history
  • Loading branch information
pacholoamit committed Jun 28, 2022
1 parent 930d7d5 commit b9aeecc
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions pkg/controllers/project.controllers.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,13 @@ func (project) CreateProject(c echo.Context) error {
return c.JSON(http.StatusCreated, cp)
}

// G
func (project) GetProject(c echo.Context) error {
p := c.Param("id")
id, _ := strconv.Atoi(p)
gp, err := services.Project.GetProject(id)
if err != nil {
return echo.NewHTTPError(http.StatusNotFound, err)
return echo.NewHTTPError(http.StatusNotFound, err.Error())
}
return c.JSON(http.StatusOK, gp)
}
Expand All @@ -59,7 +60,7 @@ func (project) UpdateProject(c echo.Context) error {
up, err := services.Project.UpdateProject(id, pr)

if err != nil {
return echo.NewHTTPError(http.StatusNotFound, err)
return echo.NewHTTPError(http.StatusNotFound, err.Error())
}
return c.JSON(http.StatusOK, up)
}
Expand All @@ -69,7 +70,7 @@ func (project) DeleteProject(c echo.Context) error {
id, _ := strconv.Atoi(p)
dp, err := services.Project.DeleteProject(id)
if err != nil {
return echo.NewHTTPError(http.StatusNotFound, err)
return echo.NewHTTPError(http.StatusNotFound, err.Error())
}
return c.JSON(http.StatusOK, dp)
}

0 comments on commit b9aeecc

Please sign in to comment.