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:
@@ -13,10 +13,10 @@ func Full(c *gin.Context) {
|
||||
userIdOrig, ok := c.Get("user_id")
|
||||
if !ok {
|
||||
errorCode := new(exception.Builder).
|
||||
SetStatus(exception.ErrorStatusUser).
|
||||
SetService(exception.UserService).
|
||||
SetEndpoint(exception.UserFullEndpoint).
|
||||
SetType(exception.ErrorTypeCommon).
|
||||
SetStatus(exception.StatusUser).
|
||||
SetService(exception.ServiceUser).
|
||||
SetEndpoint(exception.EndpointUserServiceFull).
|
||||
SetType(exception.TypeCommon).
|
||||
SetOriginal(exception.CommonErrorMissingUserId).
|
||||
Build()
|
||||
utils.HttpResponse(c, 403, errorCode)
|
||||
@@ -25,10 +25,10 @@ func Full(c *gin.Context) {
|
||||
userId, err := uuid.Parse(userIdOrig.(string))
|
||||
if err != nil {
|
||||
errorCode := new(exception.Builder).
|
||||
SetStatus(exception.ErrorStatusServer).
|
||||
SetService(exception.UserService).
|
||||
SetEndpoint(exception.UserFullEndpoint).
|
||||
SetType(exception.ErrorTypeCommon).
|
||||
SetStatus(exception.StatusServer).
|
||||
SetService(exception.ServiceUser).
|
||||
SetEndpoint(exception.EndpointUserServiceFull).
|
||||
SetType(exception.TypeCommon).
|
||||
SetOriginal(exception.CommonErrorUuidParseFailed).
|
||||
Build()
|
||||
utils.HttpResponse(c, 500, errorCode)
|
||||
@@ -38,10 +38,10 @@ func Full(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.UserFullEndpoint).
|
||||
SetType(exception.ErrorTypeCommon).
|
||||
SetStatus(exception.StatusUser).
|
||||
SetService(exception.ServiceUser).
|
||||
SetEndpoint(exception.EndpointUserServiceFull).
|
||||
SetType(exception.TypeCommon).
|
||||
SetOriginal(exception.CommonErrorUserNotFound).
|
||||
Build()
|
||||
utils.HttpResponse(c, 404, errorCode)
|
||||
@@ -51,10 +51,10 @@ func Full(c *gin.Context) {
|
||||
users, err := userData.GetFullTable()
|
||||
if err != nil {
|
||||
errorCode := new(exception.Builder).
|
||||
SetStatus(exception.ErrorStatusServer).
|
||||
SetService(exception.UserService).
|
||||
SetEndpoint(exception.UserFullEndpoint).
|
||||
SetType(exception.ErrorTypeCommon).
|
||||
SetStatus(exception.StatusServer).
|
||||
SetService(exception.ServiceUser).
|
||||
SetEndpoint(exception.EndpointUserServiceFull).
|
||||
SetType(exception.TypeCommon).
|
||||
SetOriginal(exception.CommonErrorDatabase).
|
||||
Build()
|
||||
utils.HttpResponse(c, 500, errorCode)
|
||||
|
||||
@@ -14,10 +14,10 @@ func Info(c *gin.Context) {
|
||||
userIdOrig, ok := c.Get("user_id")
|
||||
if !ok {
|
||||
errorCode := new(exception.Builder).
|
||||
SetStatus(exception.ErrorStatusUser).
|
||||
SetService(exception.UserService).
|
||||
SetEndpoint(exception.UserInfoEndpoint).
|
||||
SetType(exception.ErrorTypeCommon).
|
||||
SetStatus(exception.StatusUser).
|
||||
SetService(exception.ServiceUser).
|
||||
SetEndpoint(exception.EndpointUserServiceInfo).
|
||||
SetType(exception.TypeCommon).
|
||||
SetOriginal(exception.CommonErrorMissingUserId).
|
||||
Build()
|
||||
utils.HttpResponse(c, 403, errorCode)
|
||||
@@ -26,10 +26,10 @@ func Info(c *gin.Context) {
|
||||
userId, err := uuid.Parse(userIdOrig.(string))
|
||||
if err != nil {
|
||||
errorCode := new(exception.Builder).
|
||||
SetStatus(exception.ErrorStatusServer).
|
||||
SetService(exception.UserService).
|
||||
SetEndpoint(exception.UserInfoEndpoint).
|
||||
SetType(exception.ErrorTypeCommon).
|
||||
SetStatus(exception.StatusServer).
|
||||
SetService(exception.ServiceUser).
|
||||
SetEndpoint(exception.EndpointUserServiceInfo).
|
||||
SetType(exception.TypeCommon).
|
||||
SetOriginal(exception.CommonErrorUuidParseFailed).
|
||||
Build()
|
||||
utils.HttpResponse(c, 500, errorCode)
|
||||
@@ -40,10 +40,10 @@ func Info(c *gin.Context) {
|
||||
user, err := userData.GetByUserId(userId)
|
||||
if err != nil {
|
||||
errorCode := new(exception.Builder).
|
||||
SetStatus(exception.ErrorStatusUser).
|
||||
SetService(exception.UserService).
|
||||
SetEndpoint(exception.UserInfoEndpoint).
|
||||
SetType(exception.ErrorTypeCommon).
|
||||
SetStatus(exception.StatusUser).
|
||||
SetService(exception.ServiceUser).
|
||||
SetEndpoint(exception.EndpointUserServiceInfo).
|
||||
SetType(exception.TypeCommon).
|
||||
SetOriginal(exception.CommonErrorUserNotFound).
|
||||
Build()
|
||||
utils.HttpResponse(c, 404, errorCode)
|
||||
|
||||
@@ -18,10 +18,10 @@ func List(c *gin.Context) {
|
||||
offset, ok := c.GetQuery("offset")
|
||||
if !ok {
|
||||
errorCode := new(exception.Builder).
|
||||
SetStatus(exception.ErrorStatusClient).
|
||||
SetService(exception.UserService).
|
||||
SetEndpoint(exception.UserListEndpoint).
|
||||
SetType(exception.ErrorTypeCommon).
|
||||
SetStatus(exception.StatusClient).
|
||||
SetService(exception.ServiceUser).
|
||||
SetEndpoint(exception.EndpointUserServiceList).
|
||||
SetType(exception.TypeCommon).
|
||||
SetOriginal(exception.CommonErrorInvalidInput).
|
||||
Build()
|
||||
utils.HttpResponse(c, 400, errorCode)
|
||||
@@ -32,10 +32,10 @@ func List(c *gin.Context) {
|
||||
limitNum, err := strconv.ParseInt(limit, 10, 64)
|
||||
if err != nil {
|
||||
errorCode := new(exception.Builder).
|
||||
SetStatus(exception.ErrorStatusClient).
|
||||
SetService(exception.UserService).
|
||||
SetEndpoint(exception.UserListEndpoint).
|
||||
SetType(exception.ErrorTypeCommon).
|
||||
SetStatus(exception.StatusClient).
|
||||
SetService(exception.ServiceUser).
|
||||
SetEndpoint(exception.EndpointUserServiceList).
|
||||
SetType(exception.TypeCommon).
|
||||
SetOriginal(exception.CommonErrorInvalidInput).
|
||||
Build()
|
||||
utils.HttpResponse(c, 400, errorCode)
|
||||
@@ -44,10 +44,10 @@ func List(c *gin.Context) {
|
||||
offsetNum, err := strconv.ParseInt(offset, 10, 64)
|
||||
if err != nil {
|
||||
errorCode := new(exception.Builder).
|
||||
SetStatus(exception.ErrorStatusClient).
|
||||
SetService(exception.UserService).
|
||||
SetEndpoint(exception.UserListEndpoint).
|
||||
SetType(exception.ErrorTypeCommon).
|
||||
SetStatus(exception.StatusClient).
|
||||
SetService(exception.ServiceUser).
|
||||
SetEndpoint(exception.EndpointUserServiceList).
|
||||
SetType(exception.TypeCommon).
|
||||
SetOriginal(exception.CommonErrorInvalidInput).
|
||||
Build()
|
||||
utils.HttpResponse(c, 400, errorCode)
|
||||
@@ -58,10 +58,10 @@ func List(c *gin.Context) {
|
||||
list, err := new(data.User).FastListUsers(limitNum, offsetNum)
|
||||
if err != nil {
|
||||
errorCode := new(exception.Builder).
|
||||
SetStatus(exception.ErrorStatusServer).
|
||||
SetService(exception.UserService).
|
||||
SetEndpoint(exception.UserListEndpoint).
|
||||
SetType(exception.ErrorTypeSpecific).
|
||||
SetStatus(exception.StatusServer).
|
||||
SetService(exception.ServiceUser).
|
||||
SetEndpoint(exception.EndpointUserServiceList).
|
||||
SetType(exception.TypeSpecific).
|
||||
SetOriginal(exception.UserListMeilisearchFailed).
|
||||
Build()
|
||||
utils.HttpResponse(c, 500, errorCode)
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user