From 475250ded510536642818d8594ce35d36dcc1e8c Mon Sep 17 00:00:00 2001 From: Noah Lee Date: Wed, 8 Dec 2021 20:41:39 +0900 Subject: [PATCH] Fix the bug of handling GetConfig (#255) --- internal/server/api/v1/repos/deployment.go | 6 +++--- internal/server/api/v1/repos/lock.go | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/server/api/v1/repos/deployment.go b/internal/server/api/v1/repos/deployment.go index 0aa854f0..05d919f0 100644 --- a/internal/server/api/v1/repos/deployment.go +++ b/internal/server/api/v1/repos/deployment.go @@ -86,7 +86,7 @@ func (r *Repo) CreateDeployment(c *gin.Context) { re := vr.(*ent.Repo) config, err := r.i.GetConfig(ctx, u, re) - if e.HasErrorCode(err, e.ErrorCodeEntityNotFound) { + if err != nil { r.log.Check(gb.GetZapLogLevel(err), "Failed to get the configuration.").Write(zap.Error(err)) gb.ResponseWithStatusAndError(c, http.StatusUnprocessableEntity, err) return @@ -158,7 +158,7 @@ func (r *Repo) UpdateDeployment(c *gin.Context) { } config, err := r.i.GetConfig(ctx, u, re) - if e.HasErrorCode(err, e.ErrorCodeEntityNotFound) { + if err != nil { r.log.Check(gb.GetZapLogLevel(err), "Failed to get the configuration.").Write(zap.Error(err)) gb.ResponseWithStatusAndError(c, http.StatusUnprocessableEntity, err) return @@ -221,7 +221,7 @@ func (r *Repo) RollbackDeployment(c *gin.Context) { } config, err := r.i.GetConfig(ctx, u, re) - if e.HasErrorCode(err, e.ErrorCodeEntityNotFound) { + if err != nil { r.log.Check(gb.GetZapLogLevel(err), "Failed to get the configuration.").Write(zap.Error(err)) gb.ResponseWithStatusAndError(c, http.StatusUnprocessableEntity, err) return diff --git a/internal/server/api/v1/repos/lock.go b/internal/server/api/v1/repos/lock.go index 755d1230..7a0f8396 100644 --- a/internal/server/api/v1/repos/lock.go +++ b/internal/server/api/v1/repos/lock.go @@ -86,7 +86,7 @@ func (r *Repo) CreateLock(c *gin.Context) { u := vu.(*ent.User) config, err := r.i.GetConfig(ctx, u, re) - if e.HasErrorCode(err, e.ErrorCodeEntityNotFound) { + if err != nil { r.log.Check(gb.GetZapLogLevel(err), "Failed to get the configuration.").Write(zap.Error(err)) gb.ResponseWithStatusAndError(c, http.StatusUnprocessableEntity, err) return