chore: stabilize chatwoot parity baseline
This commit is contained in:
@@ -2,6 +2,7 @@ package v1
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
@@ -289,8 +290,17 @@ func (h *MessageHandler) Translate(c *gin.Context) {
|
||||
|
||||
result, svcErr := h.svc.Translate(c.Request.Context(), accountID, messageID, req)
|
||||
if svcErr != nil {
|
||||
handleServiceError(c, svcErr)
|
||||
lower := strings.ToLower(svcErr.Error())
|
||||
if strings.Contains(lower, "not found") {
|
||||
response.AbortWithStatusError(c, http.StatusNotFound, response.ErrNotFound, svcErr.Error())
|
||||
return
|
||||
}
|
||||
if strings.Contains(lower, "required") || strings.Contains(lower, "invalid") {
|
||||
response.AbortWithStatusError(c, http.StatusBadRequest, response.ErrValidation, svcErr.Error())
|
||||
return
|
||||
}
|
||||
response.AbortWithStatusError(c, http.StatusUnprocessableEntity, response.ErrInternal, svcErr.Error())
|
||||
return
|
||||
}
|
||||
response.OK(c, result)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user