From 986f63c0af6ead62a0f925f7e7a58e1a5b69f4f4 Mon Sep 17 00:00:00 2001 From: Asai Neko Date: Wed, 21 Jan 2026 19:37:20 +0800 Subject: [PATCH] Add context for all exceptions Signed-off-by: Asai Neko --- internal/exception/builder.go | 5 +++-- internal/exception/error.go | 15 +++++++++------ middleware/api_version.go | 2 +- middleware/jwt.go | 2 +- middleware/permission.go | 8 ++++---- service/auth/exchange.go | 14 +++++++------- service/auth/magic.go | 12 ++++++------ service/auth/redirect.go | 20 ++++++++++---------- service/auth/refresh.go | 8 ++++---- service/auth/token.go | 10 +++++----- service/event/checkin.go | 26 +++++++++++++------------- service/event/info.go | 8 ++++---- service/user/full.go | 10 +++++----- service/user/info.go | 8 ++++---- service/user/list.go | 10 +++++----- service/user/update.go | 20 ++++++++++---------- 16 files changed, 91 insertions(+), 87 deletions(-) diff --git a/internal/exception/builder.go b/internal/exception/builder.go index ff45eb8..ec71051 100644 --- a/internal/exception/builder.go +++ b/internal/exception/builder.go @@ -1,6 +1,7 @@ package exception import ( + "context" "fmt" ) @@ -50,7 +51,7 @@ func (self *Builder) SetError(e error) *Builder { return self } -func (self *Builder) Build() string { +func (self *Builder) Build(ctx context.Context) string { errorCode := fmt.Sprintf("%s%s%s%s%s", self.Status, self.Service, @@ -59,7 +60,7 @@ func (self *Builder) Build() string { self.Original, ) if self.Error != nil { - ErrorHandler(self.Status, errorCode, self.Error) + ErrorHandler(ctx, self.Status, errorCode, self.Error) } return errorCode } diff --git a/internal/exception/error.go b/internal/exception/error.go index 06a3c7a..c7ab181 100644 --- a/internal/exception/error.go +++ b/internal/exception/error.go @@ -1,16 +1,19 @@ package exception -import "log/slog" +import ( + "context" + "log/slog" +) -func ErrorHandler(status string, errorCode string, err error) { +func ErrorHandler(ctx context.Context, status string, errorCode string, err error) { switch status { case StatusSuccess: - slog.Info("Service exception", "id", errorCode, "err", err) + slog.InfoContext(ctx, "Service exception! ErrId: "+errorCode, "id", errorCode, "err", err) case StatusUser: - slog.Warn("Service exception", "id", errorCode, "err", err) + slog.WarnContext(ctx, "Service exception! ErrId: "+errorCode, "id", errorCode, "err", err) case StatusServer: - slog.Error("Service exception", "id", errorCode, "err", err) + slog.ErrorContext(ctx, "Service exception! ErrId: "+errorCode, "id", errorCode, "err", err) case StatusClient: - slog.Error("Service exception", "id", errorCode, "err", err) + slog.ErrorContext(ctx, "Service exception! ErrId: "+errorCode, "id", errorCode, "err", err) } } diff --git a/middleware/api_version.go b/middleware/api_version.go index 6b60d93..bcfdd57 100644 --- a/middleware/api_version.go +++ b/middleware/api_version.go @@ -17,7 +17,7 @@ func ApiVersionCheck() gin.HandlerFunc { SetEndpoint(exception.EndpointMiddlewareService). SetType(exception.TypeSpecific). SetOriginal(exception.ApiVersionNotFound). - Build() + Build(c) utils.HttpAbort(c, 400, errorCode) return } diff --git a/middleware/jwt.go b/middleware/jwt.go index 8e84fc2..33d22fe 100644 --- a/middleware/jwt.go +++ b/middleware/jwt.go @@ -23,7 +23,7 @@ func JWTAuth() gin.HandlerFunc { SetType(exception.TypeCommon). SetOriginal(exception.CommonErrorUnauthorized). SetError(err). - Build() + Build(c) utils.HttpAbort(c, 401, errorCode) return diff --git a/middleware/permission.go b/middleware/permission.go index 00425b9..a4191c3 100644 --- a/middleware/permission.go +++ b/middleware/permission.go @@ -22,7 +22,7 @@ func Permission(requiredLevel uint) gin.HandlerFunc { SetEndpoint(exception.EndpointMiddlewareService). SetType(exception.TypeCommon). SetOriginal(exception.CommonErrorMissingUserId). - Build() + Build(c) utils.HttpAbort(c, 401, errorCode) return } @@ -36,7 +36,7 @@ func Permission(requiredLevel uint) gin.HandlerFunc { SetType(exception.TypeCommon). SetOriginal(exception.CommonErrorUuidParseFailed). SetError(err). - Build() + Build(c) utils.HttpAbort(c, 500, errorCode) return } @@ -50,7 +50,7 @@ func Permission(requiredLevel uint) gin.HandlerFunc { SetType(exception.TypeCommon). SetOriginal(exception.CommonErrorUserNotFound). SetError(err). - Build() + Build(c) utils.HttpAbort(c, 404, errorCode) return } @@ -68,7 +68,7 @@ func Permission(requiredLevel uint) gin.HandlerFunc { SetEndpoint(exception.EndpointMiddlewareService). SetType(exception.TypeCommon). SetOriginal(exception.CommonErrorPermissionDenied). - Build() + Build(c) utils.HttpAbort(c, 403, errorCode) return } diff --git a/service/auth/exchange.go b/service/auth/exchange.go index 334c0c2..89fe02e 100644 --- a/service/auth/exchange.go +++ b/service/auth/exchange.go @@ -31,7 +31,7 @@ func Exchange(c *gin.Context) { SetType(exception.TypeCommon). SetOriginal(exception.CommonErrorInvalidInput). SetError(err). - Build() + Build(c) utils.HttpResponse(c, 400, errorCode) return } @@ -44,7 +44,7 @@ func Exchange(c *gin.Context) { SetEndpoint(exception.EndpointAuthServiceExchange). SetType(exception.TypeCommon). SetOriginal(exception.CommonErrorUnauthorized). - Build() + Build(c) utils.HttpResponse(c, 401, errorCode) return } @@ -58,7 +58,7 @@ func Exchange(c *gin.Context) { SetType(exception.TypeCommon). SetOriginal(exception.CommonErrorUuidParseFailed). SetError(err). - Build() + Build(c) utils.HttpResponse(c, 500, errorCode) return } @@ -73,7 +73,7 @@ func Exchange(c *gin.Context) { SetType(exception.TypeSpecific). SetOriginal(exception.AuthExchangeGetUserIdFailed). SetError(err). - Build() + Build(c) utils.HttpResponse(c, 500, errorCode) return } @@ -87,7 +87,7 @@ func Exchange(c *gin.Context) { SetType(exception.TypeSpecific). SetOriginal(exception.AuthExchangeCodeGenFailed). SetError(err). - Build() + Build(c) utils.HttpResponse(c, 500, errorCode) return } @@ -101,7 +101,7 @@ func Exchange(c *gin.Context) { SetType(exception.TypeSpecific). SetOriginal(exception.AuthExchangeInvalidRedirectUri). SetError(err). - Build() + Build(c) utils.HttpResponse(c, 400, errorCode) return } @@ -119,6 +119,6 @@ func Exchange(c *gin.Context) { SetEndpoint(exception.EndpointAuthServiceExchange). SetType(exception.TypeCommon). SetOriginal(exception.CommonSuccess). - Build() + Build(c) utils.HttpResponse(c, 200, errorCode, exchangeResp) } diff --git a/service/auth/magic.go b/service/auth/magic.go index 68cd1d6..a5a7568 100644 --- a/service/auth/magic.go +++ b/service/auth/magic.go @@ -31,7 +31,7 @@ func Magic(c *gin.Context) { SetType(exception.TypeCommon). SetOriginal(exception.CommonErrorInvalidInput). SetError(err). - Build() + Build(c) utils.HttpResponse(c, 400, errorCode) return } @@ -46,7 +46,7 @@ func Magic(c *gin.Context) { SetType(exception.TypeSpecific). SetOriginal(exception.AuthMagicTurnstileFailed). SetError(err). - Build() + Build(c) utils.HttpResponse(c, 403, errorCode) return } @@ -60,7 +60,7 @@ func Magic(c *gin.Context) { SetType(exception.TypeSpecific). SetOriginal(exception.AuthMagicCodeGenFailed). SetError(err). - Build() + Build(c) utils.HttpResponse(c, 500, errorCode) return } @@ -75,7 +75,7 @@ func Magic(c *gin.Context) { SetType(exception.TypeSpecific). SetOriginal(exception.AuthMagicInvalidExternalUrl). SetError(err). - Build() + Build(c) utils.HttpResponse(c, 500, errorCode) return } @@ -106,7 +106,7 @@ func Magic(c *gin.Context) { SetType(exception.TypeSpecific). SetOriginal(exception.AuthMagicInvalidEmailConfig). SetError(err). - Build() + Build(c) utils.HttpResponse(c, 500, errorCode) return } @@ -124,6 +124,6 @@ func Magic(c *gin.Context) { SetEndpoint(exception.EndpointAuthServiceMagic). SetType(exception.TypeCommon). SetOriginal(exception.CommonSuccess). - Build() + Build(c) utils.HttpResponse(c, 200, errorCode) } diff --git a/service/auth/redirect.go b/service/auth/redirect.go index 4b9a386..67a5e33 100644 --- a/service/auth/redirect.go +++ b/service/auth/redirect.go @@ -21,7 +21,7 @@ func Redirect(c *gin.Context) { SetEndpoint(exception.EndpointAuthServiceRedirect). SetType(exception.TypeCommon). SetOriginal(exception.CommonErrorInvalidInput). - Build() + Build(c) utils.HttpResponse(c, 400, errorCode) return } @@ -34,7 +34,7 @@ func Redirect(c *gin.Context) { SetEndpoint(exception.EndpointAuthServiceRedirect). SetType(exception.TypeCommon). SetOriginal(exception.CommonErrorInvalidInput). - Build() + Build(c) utils.HttpResponse(c, 400, errorCode) return } @@ -47,7 +47,7 @@ func Redirect(c *gin.Context) { SetEndpoint(exception.EndpointAuthServiceRedirect). SetType(exception.TypeCommon). SetOriginal(exception.CommonErrorInvalidInput). - Build() + Build(c) utils.HttpResponse(c, 400, errorCode) return } @@ -63,7 +63,7 @@ func Redirect(c *gin.Context) { SetEndpoint(exception.EndpointAuthServiceRedirect). SetType(exception.TypeSpecific). SetOriginal(exception.AuthRedirectTokenInvalid). - Build() + Build(c) utils.HttpResponse(c, 403, errorCode) return } @@ -88,7 +88,7 @@ func Redirect(c *gin.Context) { SetType(exception.TypeCommon). SetOriginal(exception.CommonErrorInternal). SetError(err). - Build() + Build(c) utils.HttpResponse(c, 500, errorCode) return } @@ -100,7 +100,7 @@ func Redirect(c *gin.Context) { SetType(exception.TypeCommon). SetOriginal(exception.CommonErrorInternal). SetError(err). - Build() + Build(c) utils.HttpResponse(c, 500, errorCode) return } @@ -116,7 +116,7 @@ func Redirect(c *gin.Context) { SetType(exception.TypeSpecific). SetOriginal(exception.AuthRedirectClientNotFound). SetError(err). - Build() + Build(c) utils.HttpResponse(c, 400, errorCode) return } @@ -130,7 +130,7 @@ func Redirect(c *gin.Context) { SetType(exception.TypeSpecific). SetOriginal(exception.AuthRedirectUriMismatch). SetError(err). - Build() + Build(c) utils.HttpResponse(c, 400, errorCode) return } @@ -144,7 +144,7 @@ func Redirect(c *gin.Context) { SetType(exception.TypeCommon). SetOriginal(exception.CommonErrorInternal). SetError(err). - Build() + Build(c) utils.HttpResponse(c, 500, errorCode) return } @@ -158,7 +158,7 @@ func Redirect(c *gin.Context) { SetType(exception.TypeSpecific). SetOriginal(exception.AuthRedirectInvalidUri). SetError(err). - Build() + Build(c) utils.HttpResponse(c, 400, errorCode) return } diff --git a/service/auth/refresh.go b/service/auth/refresh.go index bfa839c..248fd05 100644 --- a/service/auth/refresh.go +++ b/service/auth/refresh.go @@ -22,7 +22,7 @@ func Refresh(c *gin.Context) { SetType(exception.TypeCommon). SetOriginal(exception.CommonErrorInvalidInput). SetError(err). - Build() + Build(c) utils.HttpResponse(c, 400, errorCode) return } @@ -40,7 +40,7 @@ func Refresh(c *gin.Context) { SetType(exception.TypeSpecific). SetOriginal(exception.AuthRefreshInvalidToken). SetError(err). - Build() + Build(c) utils.HttpResponse(c, 401, errorCode) return } @@ -54,7 +54,7 @@ func Refresh(c *gin.Context) { SetType(exception.TypeSpecific). SetOriginal(exception.AuthRefreshRenewFailed). SetError(err). - Build() + Build(c) utils.HttpResponse(c, 500, errorCode) return } @@ -70,6 +70,6 @@ func Refresh(c *gin.Context) { SetEndpoint(exception.EndpointAuthServiceRefresh). SetType(exception.TypeCommon). SetOriginal(exception.CommonSuccess). - Build() + Build(c) utils.HttpResponse(c, 200, errorCode, tokenResp) } diff --git a/service/auth/token.go b/service/auth/token.go index 7020327..a050496 100644 --- a/service/auth/token.go +++ b/service/auth/token.go @@ -27,7 +27,7 @@ func Token(c *gin.Context) { SetType(exception.TypeCommon). SetOriginal(exception.CommonErrorInvalidInput). SetError(err). - Build() + Build(c) utils.HttpResponse(c, 400, errorCode) return } @@ -40,7 +40,7 @@ func Token(c *gin.Context) { SetEndpoint(exception.EndpointAuthServiceToken). SetType(exception.TypeSpecific). SetOriginal(exception.AuthTokenInvalidToken). - Build() + Build(c) utils.HttpResponse(c, 403, errorCode) return } @@ -55,7 +55,7 @@ func Token(c *gin.Context) { SetType(exception.TypeCommon). SetOriginal(exception.CommonErrorInternal). SetError(err). - Build() + Build(c) utils.HttpResponse(c, 500, errorCode) return } @@ -73,7 +73,7 @@ func Token(c *gin.Context) { SetType(exception.TypeSpecific). SetOriginal(exception.AuthTokenGenFailed). SetError(err). - Build() + Build(c) utils.HttpResponse(c, 500, errorCode) return } @@ -89,6 +89,6 @@ func Token(c *gin.Context) { SetEndpoint(exception.EndpointAuthServiceToken). SetType(exception.TypeCommon). SetOriginal(exception.CommonSuccess). - Build() + Build(c) utils.HttpResponse(c, 200, errorCode, tokenResp) } diff --git a/service/event/checkin.go b/service/event/checkin.go index 23e478c..5205c62 100644 --- a/service/event/checkin.go +++ b/service/event/checkin.go @@ -20,7 +20,7 @@ func Checkin(c *gin.Context) { SetEndpoint(exception.EndpointEventServiceCheckin). SetType(exception.TypeCommon). SetOriginal(exception.CommonErrorMissingUserId). - Build() + Build(c) utils.HttpResponse(c, 403, errorCode) return } @@ -33,7 +33,7 @@ func Checkin(c *gin.Context) { SetType(exception.TypeCommon). SetOriginal(exception.CommonErrorUuidParseFailed). SetError(err). - Build() + Build(c) utils.HttpResponse(c, 500, errorCode) } @@ -46,7 +46,7 @@ func Checkin(c *gin.Context) { SetEndpoint(exception.EndpointEventServiceCheckin). SetType(exception.TypeCommon). SetOriginal(exception.CommonErrorInvalidInput). - Build() + Build(c) utils.HttpResponse(c, 400, errorCode) return } @@ -61,7 +61,7 @@ func Checkin(c *gin.Context) { SetType(exception.TypeCommon). SetOriginal(exception.CommonErrorUuidParseFailed). SetError(err). - Build() + Build(c) utils.HttpResponse(c, 500, errorCode) return } @@ -75,7 +75,7 @@ func Checkin(c *gin.Context) { SetType(exception.TypeSpecific). SetOriginal(exception.EventCheckinGenCodeFailed). SetError(err). - Build() + Build(c) utils.HttpResponse(c, 500, errorCode) return } @@ -102,7 +102,7 @@ func CheckinSubmit(c *gin.Context) { SetType(exception.TypeCommon). SetOriginal(exception.CommonErrorInvalidInput). SetError(err). - Build() + Build(c) utils.HttpResponse(c, 400, errorCode) return } @@ -119,7 +119,7 @@ func CheckinQuery(c *gin.Context) { SetEndpoint(exception.EndpointEventServiceCheckinQuery). SetType(exception.TypeCommon). SetOriginal(exception.CommonErrorMissingUserId). - Build() + Build(c) utils.HttpResponse(c, 400, errorCode) return } @@ -132,7 +132,7 @@ func CheckinQuery(c *gin.Context) { SetType(exception.TypeCommon). SetOriginal(exception.CommonErrorUuidParseFailed). SetError(err). - Build() + Build(c) utils.HttpResponse(c, 500, errorCode) return } @@ -145,7 +145,7 @@ func CheckinQuery(c *gin.Context) { SetEndpoint(exception.EndpointEventServiceCheckinQuery). SetType(exception.TypeCommon). SetOriginal(exception.CommonErrorInvalidInput). - Build() + Build(c) utils.HttpResponse(c, 400, errorCode) return } @@ -158,7 +158,7 @@ func CheckinQuery(c *gin.Context) { SetType(exception.TypeCommon). SetOriginal(exception.CommonErrorInvalidInput). SetError(err). - Build() + Build(c) utils.HttpResponse(c, 400, errorCode) return } @@ -174,7 +174,7 @@ func CheckinQuery(c *gin.Context) { SetType(exception.TypeCommon). SetOriginal(exception.CommonErrorDatabase). SetError(err). - Build() + Build(c) utils.HttpResponse(c, 500, errorCode) return } else if attendance == nil { @@ -184,7 +184,7 @@ func CheckinQuery(c *gin.Context) { SetEndpoint(exception.EndpointEventServiceCheckinQuery). SetType(exception.TypeSpecific). SetOriginal(exception.EventCheckinQueryRecordNotFound). - Build() + Build(c) utils.HttpResponse(c, 404, errorCode) return } else if attendance.CheckinAt.IsZero() { @@ -202,6 +202,6 @@ func CheckinQuery(c *gin.Context) { SetEndpoint(exception.EndpointEventServiceCheckinQuery). SetType(exception.TypeCommon). SetOriginal(exception.CommonSuccess). - Build() + Build(c) utils.HttpResponse(c, 200, errorCode, checkInAtResp) } diff --git a/service/event/info.go b/service/event/info.go index 18161bf..351de99 100644 --- a/service/event/info.go +++ b/service/event/info.go @@ -20,7 +20,7 @@ func Info(c *gin.Context) { SetEndpoint(exception.EndpointEventServiceInfo). SetType(exception.TypeCommon). SetOriginal(exception.CommonErrorInvalidInput). - Build() + Build(c) utils.HttpResponse(c, 400, errorCode) return } @@ -35,7 +35,7 @@ func Info(c *gin.Context) { SetType(exception.TypeCommon). SetOriginal(exception.CommonErrorUuidParseFailed). SetError(err). - Build() + Build(c) utils.HttpResponse(c, 500, errorCode) return } @@ -49,7 +49,7 @@ func Info(c *gin.Context) { SetType(exception.TypeSpecific). SetOriginal(exception.EventInfoNotFound). SetError(err). - Build() + Build(c) utils.HttpResponse(c, 404, errorCode) return } @@ -66,6 +66,6 @@ func Info(c *gin.Context) { SetEndpoint(exception.EndpointEventServiceInfo). SetType(exception.TypeCommon). SetOriginal(exception.CommonSuccess). - Build() + Build(c) utils.HttpResponse(c, 200, errorCode, eventInfoResp) } diff --git a/service/user/full.go b/service/user/full.go index 9fcd99f..8b7f0fa 100644 --- a/service/user/full.go +++ b/service/user/full.go @@ -18,7 +18,7 @@ func Full(c *gin.Context) { SetEndpoint(exception.EndpointUserServiceFull). SetType(exception.TypeCommon). SetOriginal(exception.CommonErrorMissingUserId). - Build() + Build(c) utils.HttpResponse(c, 403, errorCode) return } @@ -31,7 +31,7 @@ func Full(c *gin.Context) { SetType(exception.TypeCommon). SetOriginal(exception.CommonErrorUuidParseFailed). SetError(err). - Build() + Build(c) utils.HttpResponse(c, 500, errorCode) return } @@ -45,7 +45,7 @@ func Full(c *gin.Context) { SetType(exception.TypeCommon). SetOriginal(exception.CommonErrorUserNotFound). SetError(err). - Build() + Build(c) utils.HttpResponse(c, 404, errorCode) return } @@ -59,7 +59,7 @@ func Full(c *gin.Context) { SetType(exception.TypeCommon). SetOriginal(exception.CommonErrorDatabase). SetError(err). - Build() + Build(c) utils.HttpResponse(c, 500, errorCode) return } @@ -73,6 +73,6 @@ func Full(c *gin.Context) { SetEndpoint(exception.EndpointUserServiceFull). SetType(exception.TypeCommon). SetOriginal(exception.CommonSuccess). - Build() + Build(c) utils.HttpResponse(c, 200, errorCode, userFullResp) } diff --git a/service/user/info.go b/service/user/info.go index 778fd3f..eea97ae 100644 --- a/service/user/info.go +++ b/service/user/info.go @@ -19,7 +19,7 @@ func Info(c *gin.Context) { SetEndpoint(exception.EndpointUserServiceInfo). SetType(exception.TypeCommon). SetOriginal(exception.CommonErrorMissingUserId). - Build() + Build(c) utils.HttpResponse(c, 403, errorCode) return } @@ -32,7 +32,7 @@ func Info(c *gin.Context) { SetType(exception.TypeCommon). SetOriginal(exception.CommonErrorUuidParseFailed). SetError(err). - Build() + Build(c) utils.HttpResponse(c, 500, errorCode) return } @@ -47,7 +47,7 @@ func Info(c *gin.Context) { SetType(exception.TypeCommon). SetOriginal(exception.CommonErrorUserNotFound). SetError(err). - Build() + Build(c) utils.HttpResponse(c, 404, errorCode) return } @@ -69,6 +69,6 @@ func Info(c *gin.Context) { SetEndpoint(exception.EndpointUserServiceInfo). SetType(exception.TypeCommon). SetOriginal(exception.CommonSuccess). - Build() + Build(c) utils.HttpResponse(c, 200, errorCode, userInfoResp) } diff --git a/service/user/list.go b/service/user/list.go index 831253d..41d8405 100644 --- a/service/user/list.go +++ b/service/user/list.go @@ -23,7 +23,7 @@ func List(c *gin.Context) { SetEndpoint(exception.EndpointUserServiceList). SetType(exception.TypeCommon). SetOriginal(exception.CommonErrorInvalidInput). - Build() + Build(c) utils.HttpResponse(c, 400, errorCode) return } @@ -38,7 +38,7 @@ func List(c *gin.Context) { SetType(exception.TypeCommon). SetOriginal(exception.CommonErrorInvalidInput). SetError(err). - Build() + Build(c) utils.HttpResponse(c, 400, errorCode) return } @@ -51,7 +51,7 @@ func List(c *gin.Context) { SetType(exception.TypeCommon). SetOriginal(exception.CommonErrorInvalidInput). SetError(err). - Build() + Build(c) utils.HttpResponse(c, 400, errorCode) return } @@ -66,7 +66,7 @@ func List(c *gin.Context) { SetType(exception.TypeSpecific). SetOriginal(exception.UserListMeilisearchFailed). SetError(err). - Build() + Build(c) utils.HttpResponse(c, 500, errorCode) } @@ -79,6 +79,6 @@ func List(c *gin.Context) { SetEndpoint(exception.EndpointUserServiceList). SetType(exception.TypeCommon). SetOriginal(exception.CommonSuccess). - Build() + Build(c) utils.HttpResponse(c, 200, errorCode, userListResp) } diff --git a/service/user/update.go b/service/user/update.go index f003321..d400e02 100644 --- a/service/user/update.go +++ b/service/user/update.go @@ -22,7 +22,7 @@ func Update(c *gin.Context) { SetEndpoint(exception.EndpointUserServiceUpdate). SetType(exception.TypeCommon). SetOriginal(exception.CommonErrorMissingUserId). - Build() + Build(c) utils.HttpResponse(c, 403, errorCode) return } @@ -35,7 +35,7 @@ func Update(c *gin.Context) { SetType(exception.TypeCommon). SetOriginal(exception.CommonErrorUuidParseFailed). SetError(err). - Build() + Build(c) utils.HttpResponse(c, 500, errorCode) return } @@ -50,7 +50,7 @@ func Update(c *gin.Context) { SetType(exception.TypeCommon). SetOriginal(exception.CommonErrorInvalidInput). SetError(err). - Build() + Build(c) utils.HttpResponse(c, 400, errorCode) return } @@ -65,7 +65,7 @@ func Update(c *gin.Context) { SetType(exception.TypeCommon). SetOriginal(exception.CommonErrorUserNotFound). SetError(err). - Build() + Build(c) utils.HttpResponse(c, 500, errorCode) return } @@ -87,7 +87,7 @@ func Update(c *gin.Context) { SetEndpoint(exception.EndpointUserServiceUpdate). SetType(exception.TypeCommon). SetOriginal(exception.CommonErrorInvalidInput). - Build() + Build(c) utils.HttpResponse(c, 400, errorCode) return } @@ -102,7 +102,7 @@ func Update(c *gin.Context) { SetEndpoint(exception.EndpointUserServiceUpdate). SetType(exception.TypeCommon). SetOriginal(exception.CommonErrorInvalidInput). - Build() + Build(c) utils.HttpResponse(c, 400, errorCode) return } @@ -117,7 +117,7 @@ func Update(c *gin.Context) { SetEndpoint(exception.EndpointUserServiceUpdate). SetType(exception.TypeCommon). SetOriginal(exception.CommonErrorInvalidInput). - Build() + Build(c) utils.HttpResponse(c, 400, errorCode) return } @@ -134,7 +134,7 @@ func Update(c *gin.Context) { SetType(exception.TypeCommon). SetOriginal(exception.CommonErrorInvalidInput). SetError(err). - Build() + Build(c) utils.HttpResponse(c, 400, errorCode) return } @@ -149,7 +149,7 @@ func Update(c *gin.Context) { SetEndpoint(exception.EndpointUserServiceUpdate). SetType(exception.TypeCommon). SetOriginal(exception.CommonErrorInvalidInput). - Build() + Build(c) utils.HttpResponse(c, 400, errorCode) return } @@ -165,6 +165,6 @@ func Update(c *gin.Context) { SetEndpoint(exception.EndpointUserServiceUpdate). SetType(exception.TypeCommon). SetOriginal(exception.CommonSuccess). - Build() + Build(c) utils.HttpResponse(c, 200, errorCode) }