feat(captain): align custom tool limits

This commit is contained in:
2026-06-07 16:06:19 +08:00
parent 0d8de3be0b
commit dd7bcf4118
6 changed files with 166 additions and 13 deletions
@@ -1,6 +1,7 @@
package v1
import (
"errors"
"net/http"
"github.com/gin-gonic/gin"
@@ -42,6 +43,10 @@ func (h *CaptainCustomToolHandler) Create(c *gin.Context) {
tool, err := h.svc.Create(c.Request.Context(), accountID, &req)
if err != nil {
applogger.L().Errorf("Create captain custom tool: %v", err)
if errors.Is(err, service.ErrCaptainCustomToolLimitExceeded) {
c.JSON(http.StatusUnprocessableEntity, gin.H{"error": service.ErrCaptainCustomToolLimitExceeded.Error()})
return
}
response.AbortWithStatusError(c, http.StatusInternalServerError, response.ErrInternal, "failed to create custom tool")
return
}