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
+3 -3
View File
@@ -104,7 +104,7 @@ func Enabled() bool {
func BuildAuthCodeURL(next string) (string, error) {
if !Enabled() {
return "", errorsx.BusinessError(1, "OIDC 登录未启用")
return "", errorsx.BusinessErrorI18n(1, "error.oidc.loginDisabled")
}
state, err := CreateState(next)
if err != nil {
@@ -115,7 +115,7 @@ func BuildAuthCodeURL(next string) (string, error) {
func ExchangeCode(ctx context.Context, code string) (*Profile, error) {
if !Enabled() {
return nil, errorsx.BusinessError(1, "OIDC 登录未启用")
return nil, errorsx.BusinessErrorI18n(1, "error.oidc.loginDisabled")
}
code = strings.TrimSpace(code)
if code == "" {
@@ -149,7 +149,7 @@ func ExchangeCode(ctx context.Context, code string) (*Profile, error) {
func CreateState(next string) (string, error) {
secret := stateSecret()
if secret == "" {
return "", errorsx.BusinessError(2, "OIDC 登录密钥未配置")
return "", errorsx.BusinessErrorI18n(2, "error.oidc.stateSecretMissing")
}
nonce, err := randomToken("os_")
if err != nil {