aboutsummaryrefslogtreecommitdiffstats
path: root/modules/translation/i18n
diff options
context:
space:
mode:
authorwxiaoguang <wxiaoguang@gmail.com>2025-03-03 13:36:10 +0800
committerGitHub <noreply@github.com>2025-03-03 05:36:10 +0000
commit216243eee299a973e4504fc210e07c168376934e (patch)
tree62916999a7ba2da08a62f1a67153f118e44ca7d6 /modules/translation/i18n
parentdbed39d63292517918c3b1a74aeb71ac8910beb7 (diff)
downloadgitea-216243eee299a973e4504fc210e07c168376934e.tar.gz
gitea-216243eee299a973e4504fc210e07c168376934e.zip
Refactor error system (#33771)
It should not expose `util.SilentWrap` or construct it manually.
Diffstat (limited to 'modules/translation/i18n')
-rw-r--r--modules/translation/i18n/errors.go13
-rw-r--r--modules/translation/i18n/format.go3
-rw-r--r--modules/translation/i18n/localestore.go3
3 files changed, 4 insertions, 15 deletions
diff --git a/modules/translation/i18n/errors.go b/modules/translation/i18n/errors.go
deleted file mode 100644
index 7f64ccf908..0000000000
--- a/modules/translation/i18n/errors.go
+++ /dev/null
@@ -1,13 +0,0 @@
-// Copyright 2022 The Gitea Authors. All rights reserved.
-// SPDX-License-Identifier: MIT
-
-package i18n
-
-import (
- "code.gitea.io/gitea/modules/util"
-)
-
-var (
- ErrLocaleAlreadyExist = util.SilentWrap{Message: "lang already exists", Err: util.ErrAlreadyExist}
- ErrUncertainArguments = util.SilentWrap{Message: "arguments to i18n should not contain uncertain slices", Err: util.ErrInvalidArgument}
-)
diff --git a/modules/translation/i18n/format.go b/modules/translation/i18n/format.go
index e5e221831f..450509333f 100644
--- a/modules/translation/i18n/format.go
+++ b/modules/translation/i18n/format.go
@@ -4,6 +4,7 @@
package i18n
import (
+ "errors"
"fmt"
"reflect"
)
@@ -30,7 +31,7 @@ func Format(format string, args ...any) (msg string, err error) {
fmtArgs = append(fmtArgs, val.Index(i).Interface())
}
} else {
- err = ErrUncertainArguments
+ err = errors.New("arguments to i18n should not contain uncertain slices")
break
}
} else {
diff --git a/modules/translation/i18n/localestore.go b/modules/translation/i18n/localestore.go
index b422996984..4f1ae7e13d 100644
--- a/modules/translation/i18n/localestore.go
+++ b/modules/translation/i18n/localestore.go
@@ -4,6 +4,7 @@
package i18n
import (
+ "errors"
"fmt"
"html/template"
"slices"
@@ -41,7 +42,7 @@ func NewLocaleStore() LocaleStore {
// AddLocaleByIni adds locale by ini into the store
func (store *localeStore) AddLocaleByIni(langName, langDesc string, source, moreSource []byte) error {
if _, ok := store.localeMap[langName]; ok {
- return ErrLocaleAlreadyExist
+ return errors.New("lang has already been added")
}
store.langNames = append(store.langNames, langName)