Return 409 instead of 500 for duplicate project member (#14727)

Fixes #14621

Signed-off-by: stonezdj <stonezdj@gmail.com>
This commit is contained in:
stonezdj(Daojun Zhang) 2021-04-26 12:59:37 +08:00 committed by GitHub
parent 5b526b8dc7
commit c946457eef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View File

@ -68,10 +68,10 @@ type UserGroup struct {
}
// ErrDuplicateProjectMember ...
var ErrDuplicateProjectMember = errors.New("The project member specified already exist")
var ErrDuplicateProjectMember = errors.ConflictError(nil).WithMessage("The project member specified already exist")
// ErrInvalidRole ...
var ErrInvalidRole = errors.New("Failed to update project member, role is not in 1,2,3")
var ErrInvalidRole = errors.BadRequestError(nil).WithMessage("Failed to update project member, role is not in 1,2,3")
type controller struct {
userManager user.Manager

View File

@ -56,7 +56,7 @@ func New() DAO {
}
// ErrGroupNameDup ...
var ErrGroupNameDup = errors.New("duplicated user group name")
var ErrGroupNameDup = errors.ConflictError(nil).WithMessage("duplicated user group name")
// Add - Add User Group
func (d *dao) Add(ctx context.Context, userGroup model.UserGroup) (int, error) {