fix: localize validation errors and polish delivery
Build and publish Docker images / Build and publish images (push) Failing after 25s
Build and publish Docker images / Build and publish images (push) Failing after 25s
This commit is contained in:
@@ -18,6 +18,7 @@ import (
|
||||
"github.com/gochat/gochat/internal/service"
|
||||
"github.com/gochat/gochat/pkg/pagination"
|
||||
"github.com/gochat/gochat/pkg/response"
|
||||
pkgvalidator "github.com/gochat/gochat/pkg/validator"
|
||||
"gorm.io/datatypes"
|
||||
)
|
||||
|
||||
@@ -388,6 +389,10 @@ func (h *MessageHandler) Translate(c *gin.Context) {
|
||||
}
|
||||
result, svcErr := h.svc.TranslateInConversation(c.Request.Context(), accountID, conversation.ID, messageID, req)
|
||||
if svcErr != nil {
|
||||
if pkgvalidator.IsValidationError(svcErr) {
|
||||
response.AbortWithStatusError(c, http.StatusBadRequest, response.ErrValidation, pkgvalidator.ValidationMessage(svcErr))
|
||||
return
|
||||
}
|
||||
lower := strings.ToLower(svcErr.Error())
|
||||
if strings.Contains(lower, "not found") {
|
||||
response.AbortWithStatusError(c, http.StatusNotFound, response.ErrNotFound, svcErr.Error())
|
||||
|
||||
Reference in New Issue
Block a user