feat: enhance error handling with internationalized messages across services and locales

This commit is contained in:
mlogclub
2026-06-02 21:10:17 +08:00
parent 0b4a1b4594
commit 5b6c54de34
14 changed files with 109 additions and 42 deletions
@@ -90,7 +90,7 @@ func (s *customerSessionService) Sign(channel *models.Channel, customer *models.
cfg := config.Current().CustomerSession
secret := strings.TrimSpace(cfg.Secret)
if secret == "" {
return "", time.Time{}, errorsx.BusinessError(1, "客服会话密钥未配置")
return "", time.Time{}, errorsx.BusinessErrorI18n(1, "error.customerSession.secretMissing")
}
if channel == nil || customer == nil {
return "", time.Time{}, errorsx.InvalidParamI18n("error.e0158")
@@ -168,7 +168,7 @@ func (s *customerSessionService) verifyToken(rawToken string) (*customerSessionC
cfg := config.Current().CustomerSession
secret := strings.TrimSpace(cfg.Secret)
if secret == "" {
return nil, errorsx.BusinessError(1, "客服会话密钥未配置")
return nil, errorsx.BusinessErrorI18n(1, "error.customerSession.secretMissing")
}
claims := &customerSessionClaims{}
token, err := jwt.ParseWithClaims(rawToken, claims, func(token *jwt.Token) (any, error) {