This is an automated email from the ASF dual-hosted git repository. tianxiaoliang pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git
The following commit(s) were added to refs/heads/master by this push: new 90ad4fe SCB-2176 Fix: wrong quota error code (#1031) 90ad4fe is described below commit 90ad4fed05c6c0d24804b1fba6c9a8d8189b5db3 Author: little-cui <sure_0...@qq.com> AuthorDate: Mon May 31 21:21:38 2021 +0800 SCB-2176 Fix: wrong quota error code (#1031) --- server/service/rbac/account_dao.go | 6 +++--- server/service/rbac/role_dao.go | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/server/service/rbac/account_dao.go b/server/service/rbac/account_dao.go index 73ae9d1..cb800b0 100644 --- a/server/service/rbac/account_dao.go +++ b/server/service/rbac/account_dao.go @@ -34,10 +34,10 @@ import ( //CreateAccount save 2 kv //1. account info func CreateAccount(ctx context.Context, a *rbac.Account) error { - quotaCheckErr := quota.Apply(ctx, quota.NewApplyQuotaResource(quota.TypeAccount, + quotaErr := quota.Apply(ctx, quota.NewApplyQuotaResource(quota.TypeAccount, util.ParseDomainProject(ctx), "", 1)) - if quotaCheckErr != nil { - return quotaCheckErr + if quotaErr != nil { + return rbac.NewError(rbac.ErrAccountNoQuota, quotaErr.Error()) } err := validator.ValidateCreateAccount(a) if err != nil { diff --git a/server/service/rbac/role_dao.go b/server/service/rbac/role_dao.go index b9f4e3d..01896ec 100644 --- a/server/service/rbac/role_dao.go +++ b/server/service/rbac/role_dao.go @@ -41,7 +41,7 @@ func CreateRole(ctx context.Context, r *rbac.Role) (*discovery.Response, error) quotaErr := quota.Apply(ctx, quota.NewApplyQuotaResource(quota.TypeRole, util.ParseDomainProject(ctx), "", 1)) if quotaErr != nil { - return discovery.CreateResponse(discovery.ErrNotEnoughQuota, quotaErr.Error()), nil + return discovery.CreateResponse(rbac.ErrRoleNoQuota, quotaErr.Error()), nil } err = datasource.Instance().CreateRole(ctx, r) if err == nil {