feat(agents): align duplicate create errors

This commit is contained in:
2026-06-06 02:31:02 +08:00
parent dd2bdee470
commit 8b30cc78a0
3 changed files with 16 additions and 7 deletions
+4 -1
View File
@@ -111,7 +111,10 @@ func (h *AgentHandler) Create(c *gin.Context) {
agent, svcErr := h.svc.Create(c.Request.Context(), accountID, userID, req)
if svcErr != nil {
if errors.Is(svcErr, repository.ErrAlreadyMember) {
response.AbortWithStatusError(c, http.StatusConflict, response.ErrConflict, svcErr.Error())
c.JSON(http.StatusUnprocessableEntity, gin.H{
"message": "User has already been taken",
"attributes": []string{"user_id"},
})
return
}
applogger.L().Errorf("Create agent for account %d: %v", accountID, svcErr)