refactor: update exception constants to follow new naming convention

- Update old ErrorStatus, ErrorType, and Service/Endpoint constants to new naming convention
- Fix incorrect TypeSpecific usage in JWT middleware
- Add missing event specific error definitions to specific.yaml
- Regenerate exception constants

Co-authored-by: Gemini <gemini@google.com>
This commit is contained in:
2026-01-21 14:31:03 +08:00
parent b1c78dce28
commit 14f50ecdb2
12 changed files with 236 additions and 229 deletions

View File

@@ -17,10 +17,10 @@ func Update(c *gin.Context) {
userIdOrig, ok := c.Get("user_id")
if !ok {
errorCode := new(exception.Builder).
SetStatus(exception.ErrorStatusUser).
SetService(exception.UserService).
SetEndpoint(exception.UserUpdateEndpoint).
SetType(exception.ErrorTypeCommon).
SetStatus(exception.StatusUser).
SetService(exception.ServiceUser).
SetEndpoint(exception.EndpointUserServiceUpdate).
SetType(exception.TypeCommon).
SetOriginal(exception.CommonErrorMissingUserId).
Build()
utils.HttpResponse(c, 403, errorCode)
@@ -29,10 +29,10 @@ func Update(c *gin.Context) {
userId, err := uuid.Parse(userIdOrig.(string))
if err != nil {
errorCode := new(exception.Builder).
SetStatus(exception.ErrorStatusServer).
SetService(exception.UserService).
SetEndpoint(exception.UserUpdateEndpoint).
SetType(exception.ErrorTypeCommon).
SetStatus(exception.StatusServer).
SetService(exception.ServiceUser).
SetEndpoint(exception.EndpointUserServiceUpdate).
SetType(exception.TypeCommon).
SetOriginal(exception.CommonErrorUuidParseFailed).
Build()
utils.HttpResponse(c, 500, errorCode)
@@ -43,10 +43,10 @@ func Update(c *gin.Context) {
err = c.ShouldBindJSON(&ReqInfo)
if err != nil {
errorCode := new(exception.Builder).
SetStatus(exception.ErrorStatusClient).
SetService(exception.UserService).
SetEndpoint(exception.UserUpdateEndpoint).
SetType(exception.ErrorTypeCommon).
SetStatus(exception.StatusClient).
SetService(exception.ServiceUser).
SetEndpoint(exception.EndpointUserServiceUpdate).
SetType(exception.TypeCommon).
SetOriginal(exception.CommonErrorInvalidInput).
Build()
utils.HttpResponse(c, 400, errorCode)
@@ -57,10 +57,10 @@ func Update(c *gin.Context) {
userData, err := new(data.User).GetByUserId(userId)
if err != nil {
errorCode := new(exception.Builder).
SetStatus(exception.ErrorStatusUser).
SetService(exception.UserService).
SetEndpoint(exception.UserUpdateEndpoint).
SetType(exception.ErrorTypeCommon).
SetStatus(exception.StatusUser).
SetService(exception.ServiceUser).
SetEndpoint(exception.EndpointUserServiceUpdate).
SetType(exception.TypeCommon).
SetOriginal(exception.CommonErrorUserNotFound).
Build()
utils.HttpResponse(c, 500, errorCode)
@@ -79,10 +79,10 @@ func Update(c *gin.Context) {
if ReqInfo.Username != "" {
if len(ReqInfo.Username) < 5 || len(ReqInfo.Username) >= 255 {
errorCode := new(exception.Builder).
SetStatus(exception.ErrorStatusClient).
SetService(exception.UserService).
SetEndpoint(exception.UserUpdateEndpoint).
SetType(exception.ErrorTypeCommon).
SetStatus(exception.StatusClient).
SetService(exception.ServiceUser).
SetEndpoint(exception.EndpointUserServiceUpdate).
SetType(exception.TypeCommon).
SetOriginal(exception.CommonErrorInvalidInput).
Build()
utils.HttpResponse(c, 400, errorCode)
@@ -94,10 +94,10 @@ func Update(c *gin.Context) {
if ReqInfo.Nickname != "" {
if utf8.RuneCountInString(ReqInfo.Nickname) > 24 {
errorCode := new(exception.Builder).
SetStatus(exception.ErrorStatusClient).
SetService(exception.UserService).
SetEndpoint(exception.UserUpdateEndpoint).
SetType(exception.ErrorTypeCommon).
SetStatus(exception.StatusClient).
SetService(exception.ServiceUser).
SetEndpoint(exception.EndpointUserServiceUpdate).
SetType(exception.TypeCommon).
SetOriginal(exception.CommonErrorInvalidInput).
Build()
utils.HttpResponse(c, 400, errorCode)
@@ -109,10 +109,10 @@ func Update(c *gin.Context) {
if ReqInfo.Subtitle != "" {
if utf8.RuneCountInString(ReqInfo.Subtitle) > 32 {
errorCode := new(exception.Builder).
SetStatus(exception.ErrorStatusClient).
SetService(exception.UserService).
SetEndpoint(exception.UserUpdateEndpoint).
SetType(exception.ErrorTypeCommon).
SetStatus(exception.StatusClient).
SetService(exception.ServiceUser).
SetEndpoint(exception.EndpointUserServiceUpdate).
SetType(exception.TypeCommon).
SetOriginal(exception.CommonErrorInvalidInput).
Build()
utils.HttpResponse(c, 400, errorCode)
@@ -125,10 +125,10 @@ func Update(c *gin.Context) {
_, err := url.ParseRequestURI(ReqInfo.Avatar)
if err != nil {
errorCode := new(exception.Builder).
SetStatus(exception.ErrorStatusClient).
SetService(exception.UserService).
SetEndpoint(exception.UserUpdateEndpoint).
SetType(exception.ErrorTypeCommon).
SetStatus(exception.StatusClient).
SetService(exception.ServiceUser).
SetEndpoint(exception.EndpointUserServiceUpdate).
SetType(exception.TypeCommon).
SetOriginal(exception.CommonErrorInvalidInput).
Build()
utils.HttpResponse(c, 400, errorCode)
@@ -140,10 +140,10 @@ func Update(c *gin.Context) {
if ReqInfo.Bio != "" {
if !cryptography.IsBase64Std(ReqInfo.Bio) {
errorCode := new(exception.Builder).
SetStatus(exception.ErrorStatusClient).
SetService(exception.UserService).
SetEndpoint(exception.UserUpdateEndpoint).
SetType(exception.ErrorTypeCommon).
SetStatus(exception.StatusClient).
SetService(exception.ServiceUser).
SetEndpoint(exception.EndpointUserServiceUpdate).
SetType(exception.TypeCommon).
SetOriginal(exception.CommonErrorInvalidInput).
Build()
utils.HttpResponse(c, 400, errorCode)