enhance: Improve validation errors for secrets/variables (#39221)

Signed-off-by: Ross Golder <ross@golder.org>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
Ross Golder
2026-09-04 00:28:58 +00:00
committed by GitHub
co-authored by wxiaoguang
parent ce2fd8d882
commit 2d3ad4a530
19 changed files with 148 additions and 218 deletions
+17
View File
@@ -4,6 +4,7 @@
package util
import (
"fmt"
"io"
"testing"
@@ -32,3 +33,19 @@ func TestErrorTranslatable(t *testing.T) {
require.True(t, ok)
assert.Equal(t, "key", wrapped.trKey)
}
func TestErrorUnwrapForUser(t *testing.T) {
err := NewNotExistErrorf("test msg")
msg, code := ErrorUnwrapForUser(err)
assert.Equal(t, "test msg", msg)
assert.Equal(t, 404, code)
err = fmt.Errorf("other wrapper: %w", err)
msg, code = ErrorUnwrapForUser(err)
assert.Equal(t, "other wrapper: test msg", msg)
assert.Equal(t, 404, code)
msg, code = ErrorUnwrapForUser(io.EOF)
assert.Equal(t, "", msg)
assert.Equal(t, 0, code)
}