Skip to content
This repository was archived by the owner on May 30, 2024. It is now read-only.

Fix error handling of repo APIs #198

Merged
merged 23 commits into from
Oct 31, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix the error message
  • Loading branch information
noah committed Oct 31, 2021
commit ce419f3ffd55eb15ec6ad98fa14e851aaa171dcd
8 changes: 4 additions & 4 deletions internal/server/api/v1/repos/approval.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func (r *Repo) GetMyApproval(c *gin.Context) {
if number, err = strconv.Atoi(c.Param("number")); err != nil {
gb.ResponseWithError(
c,
e.NewErrorWithMessage(e.ErrorCodeInvalidRequest, "The number must be integer.", nil),
e.NewErrorWithMessage(e.ErrorCodeInvalidRequest, "The number must be number.", nil),
)
return
}
Expand Down Expand Up @@ -128,7 +128,7 @@ func (r *Repo) CreateApproval(c *gin.Context) {
if number, err = strconv.Atoi(c.Param("number")); err != nil {
gb.ResponseWithError(
c,
e.NewErrorWithMessage(e.ErrorCodeInvalidRequest, "The number must be integer.", nil),
e.NewErrorWithMessage(e.ErrorCodeInvalidRequest, "The number must be number.", nil),
)
return
}
Expand Down Expand Up @@ -214,7 +214,7 @@ func (r *Repo) UpdateMyApproval(c *gin.Context) {
if number, err = strconv.Atoi(c.Param("number")); err != nil {
gb.ResponseWithError(
c,
e.NewErrorWithMessage(e.ErrorCodeInvalidRequest, "The number must be integer.", nil),
e.NewErrorWithMessage(e.ErrorCodeInvalidRequest, "The number must be number.", nil),
)
return
}
Expand Down Expand Up @@ -282,7 +282,7 @@ func (r *Repo) DeleteApproval(c *gin.Context) {
if aid, err = strconv.Atoi(c.Param("aid")); err != nil {
gb.ResponseWithError(
c,
e.NewErrorWithMessage(e.ErrorCodeInvalidRequest, "The number must be integer.", nil),
e.NewErrorWithMessage(e.ErrorCodeInvalidRequest, "The number must be number.", nil),
)
return
}
Expand Down
6 changes: 3 additions & 3 deletions internal/server/api/v1/repos/comment.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func (r *Repo) ListComments(c *gin.Context) {
if number, err = strconv.Atoi(c.Param("number")); err != nil {
gb.ResponseWithError(
c,
e.NewErrorWithMessage(e.ErrorCodeInvalidRequest, "The number must be integer.", nil),
e.NewErrorWithMessage(e.ErrorCodeInvalidRequest, "The number must be number.", nil),
)
return
}
Expand Down Expand Up @@ -72,7 +72,7 @@ func (r *Repo) GetComment(c *gin.Context) {
if id, err = strconv.Atoi(c.Param("id")); err != nil {
gb.ResponseWithError(
c,
e.NewErrorWithMessage(e.ErrorCodeInvalidRequest, "The id must be integer.", nil),
e.NewErrorWithMessage(e.ErrorCodeInvalidRequest, "The id must be number.", nil),
)
return
}
Expand All @@ -99,7 +99,7 @@ func (r *Repo) CreateComment(c *gin.Context) {
r.log.Warn("Failed to parse 'number'.", zap.Error(err))
gb.ResponseWithError(
c,
e.NewErrorWithMessage(e.ErrorCodeInvalidRequest, "The number must be integer.", err),
e.NewErrorWithMessage(e.ErrorCodeInvalidRequest, "The number must be number.", err),
)
return
}
Expand Down
15 changes: 12 additions & 3 deletions internal/server/api/v1/repos/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,10 @@ func (r *Repo) CreateDeployment(c *gin.Context) {
var env *vo.Env
if env = cf.GetEnv(p.Env); env == nil {
r.log.Warn("The environment is not defined in the configuration.")
gb.ResponseWithStatusAndError(c, http.StatusUnprocessableEntity, err)
gb.ResponseWithError(
c,
e.NewErrorWithMessage(e.ErrorCodeConfigParseError, "The environment is not defiend in the configuration.", nil),
)
return
}

Expand Down Expand Up @@ -190,7 +193,10 @@ func (r *Repo) UpdateDeployment(c *gin.Context) {
var env *vo.Env
if env = cf.GetEnv(d.Env); env == nil {
r.log.Warn("The environment is not defined in the configuration.")
gb.ResponseWithStatusAndError(c, http.StatusUnprocessableEntity, err)
gb.ResponseWithError(
c,
e.NewErrorWithMessage(e.ErrorCodeConfigParseError, "The environment is not defiend in the configuration.", nil),
)
return
}

Expand Down Expand Up @@ -259,7 +265,10 @@ func (r *Repo) RollbackDeployment(c *gin.Context) {
var env *vo.Env
if env = cf.GetEnv(d.Env); env == nil {
r.log.Warn("The environment is not defined in the configuration.")
gb.ResponseWithStatusAndError(c, http.StatusUnprocessableEntity, err)
gb.ResponseWithError(
c,
e.NewErrorWithMessage(e.ErrorCodeConfigParseError, "The environment is not defiend in the configuration.", nil),
)
return
}

Expand Down