Skip to content

Commit

Permalink
zopsmart#3 | in case of error, nil returned instead of any string at …
Browse files Browse the repository at this point in the history
…http layer
  • Loading branch information
raybittu committed Feb 15, 2021
1 parent ca3f5da commit a472e13
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions panel/http/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ func New(service service.PanelEmployee) PanelHTTP {
func (p PanelHTTP) CreateEmployee(c *gofr.Context) (interface{}, error) {
companyID, err := strconv.Atoi(c.Request.PathParam("companyID"))
if err != nil {
return "Invalid CompanyID", customError.ErrInvalidCompanyID
return nil, customError.ErrInvalidCompanyID
}
var emp models.Employee

err = c.Request.Bind(&emp)

if err != nil {
return "Wrong json format", customError.ErrJSONFormat
return nil, customError.ErrJSONFormat
}

res, err := p.service.CreateEmployee(c, companyID, &emp)
Expand All @@ -43,7 +43,7 @@ func (p PanelHTTP) CreateEmployee(c *gofr.Context) (interface{}, error) {
func (p PanelHTTP) GetAllEmployee(c *gofr.Context) (interface{}, error) {
companyID, err := strconv.Atoi(c.Request.PathParam("companyID"))
if err != nil {
return "Invalid CompanyID", customError.ErrInvalidCompanyID
return nil, customError.ErrInvalidCompanyID
}

yoe, _ := strconv.Atoi(c.Param("yoe"))
Expand Down

0 comments on commit a472e13

Please sign in to comment.