Skip to content

Commit 4a9277e

Browse files
authored
Merge pull request #219 from kcl-lang/chore-remove-error-prefix
chore: remove error prefix in the error message
2 parents 7868e7e + 305bcd7 commit 4a9277e

File tree

33 files changed

+58
-58
lines changed

33 files changed

+58
-58
lines changed

pkg/api/kpm_run_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func TestRunPkgInPathInvalidPath(t *testing.T) {
6060
opts.SetPkgPath(filepath.Join(pkgPath, "test_kcl"))
6161
result, err := RunPkgInPath(opts)
6262
assert.NotEqual(t, err, nil)
63-
assert.Equal(t, err.Error(), fmt.Sprintf("error: failed to compile the kcl package\nerror: Cannot find the kcl file, please check the file path %s\n", filepath.Join(pkgPath, "test_kcl", "not_exist.k")))
63+
assert.Equal(t, err.Error(), fmt.Sprintf("failed to compile the kcl package\nCannot find the kcl file, please check the file path %s\n", filepath.Join(pkgPath, "test_kcl", "not_exist.k")))
6464
assert.Equal(t, result, "")
6565
}
6666

pkg/oci/oci_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,5 @@ func TestLogin(t *testing.T) {
3838
userPwd := "invalid_password"
3939

4040
err := Login(hostName, userName, userPwd, &settings)
41-
assert.Equal(t, err.Error(), "error: failed to login 'ghcr.io', please check registry, username and password is valid\nerror: Get \"https://ghcr.io/v2/\": denied: denied\n")
41+
assert.Equal(t, err.Error(), "failed to login 'ghcr.io', please check registry, username and password is valid\nGet \"https://ghcr.io/v2/\": denied: denied\n")
4242
}

pkg/package/package_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ func TestValidateKpmHome(t *testing.T) {
8787
oldValue := os.Getenv(env.PKG_PATH)
8888
os.Setenv(env.PKG_PATH, "test_home_path")
8989
err := kclPkg.ValidateKpmHome(os.Getenv(env.PKG_PATH))
90-
assert.Equal(t, err.Error(), "error: environment variable KCL_PKG_PATH cannot be set to the same path as the current KCL package.\n")
90+
assert.Equal(t, err.Error(), "environment variable KCL_PKG_PATH cannot be set to the same path as the current KCL package.\n")
9191
assert.Equal(t, err.Type(), reporter.InvalidKpmHomeInCurrentPkg)
9292
os.Setenv(env.PKG_PATH, oldValue)
9393
}

pkg/reporter/reporter.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,18 +126,18 @@ func (e *KpmEvent) Error() string {
126126
result := ""
127127
if e.msg != "" {
128128
// append msg
129-
result = fmt.Sprintf("error: %s\n", e.msg)
129+
result = fmt.Sprintf("%s\n", e.msg)
130130
}
131131
if e.err != nil {
132-
result = fmt.Sprintf("%serror: %s\n", result, e.err.Error())
132+
result = fmt.Sprintf("%s%s\n", result, e.err.Error())
133133
}
134134
return result
135135
}
136136

137137
// Event returns the msg of the event without error message.
138138
func (e *KpmEvent) Event() string {
139139
if e.msg != "" {
140-
return fmt.Sprintf("error: %s\n", e.msg)
140+
return fmt.Sprintf("%s\n", e.msg)
141141
}
142142
return ""
143143
}

pkg/semver/semver_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ func TestLatestVersion(t *testing.T) {
1717
assert.Equal(t, latest, "")
1818

1919
latest, err = LatestVersion([]string{"invalid_version"})
20-
assert.Equal(t, err.Error(), "error: failed to parse version invalid_version\nerror: Malformed version: invalid_version\n")
20+
assert.Equal(t, err.Error(), "failed to parse version invalid_version\nMalformed version: invalid_version\n")
2121
assert.Equal(t, latest, "")
2222

2323
latest, err = LatestVersion([]string{"1.2.3", "1.4.0", "1.3.5", "invalid_version"})
24-
assert.Equal(t, err.Error(), "error: failed to parse version invalid_version\nerror: Malformed version: invalid_version\n")
24+
assert.Equal(t, err.Error(), "failed to parse version invalid_version\nMalformed version: invalid_version\n")
2525
assert.Equal(t, latest, "")
2626
}
2727

pkg/settings/settings_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ func TestSettingEnv(t *testing.T) {
174174
assert.Equal(t, settings.DefaultOciRegistry(), "test_reg")
175175
assert.Equal(t, settings.DefaultOciRepo(), "test_repo")
176176
assert.Equal(t, settings.ErrorEvent.Type(), reporter.UnknownEnv)
177-
assert.Equal(t, settings.ErrorEvent.Error(), "error: unknown environment variable 'OCI_REG_PLAIN_HTTP=true'\nerror: invalid environment variable\n")
177+
assert.Equal(t, settings.ErrorEvent.Error(), "unknown environment variable 'OCI_REG_PLAIN_HTTP=true'\ninvalid environment variable\n")
178178
assert.Equal(t, settings.DefaultOciPlainHttp(), false)
179179

180180
err = os.Setenv("OCI_REG_PLAIN_HTTP", "on")
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
error: could not load 'kcl.mod' in '<workspace>/an_invalid_kcl_pkg'
1+
could not load 'kcl.mod' in '<workspace>/an_invalid_kcl_pkg'
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
error: failed to get package with 'not_exist_tag' from 'localhost:5001/test/k8s'
2-
error: failed to resolve not_exist_tag: localhost:5001/test/k8s:not_exist_tag: not found
1+
failed to get package with 'not_exist_tag' from 'localhost:5001/test/k8s'
2+
failed to resolve not_exist_tag: localhost:5001/test/k8s:not_exist_tag: not found
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
error: invalid 'kpm add' argument, you must provide a package name or url for the package
1+
invalid 'kpm add' argument, you must provide a package name or url for the package
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
error: only support url scheme 'oci://'
2-
error: invalid oci url
1+
only support url scheme 'oci://'
2+
invalid oci url
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
error: failed to compile the kcl package
2-
error: Cannot find the kcl file, please check the file path
1+
failed to compile the kcl package
2+
Cannot find the kcl file, please check the file path
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
error: could not load 'kcl.mod' in '<workspace>'
2-
error: open <workspace>/kcl.mod: no such file or directory
1+
could not load 'kcl.mod' in '<workspace>'
2+
open <workspace>/kcl.mod: no such file or directory
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
error: could not load 'kcl.mod' in '<workspace>'
2-
error: open <workspace>/kcl.mod: no such file or directory
1+
could not load 'kcl.mod' in '<workspace>'
2+
open <workspace>/kcl.mod: no such file or directory
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
error: could not load 'kcl.mod' in '<workspace>'
2-
error: open <workspace>/kcl.mod: no such file or directory
1+
could not load 'kcl.mod' in '<workspace>'
2+
open <workspace>/kcl.mod: no such file or directory
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
error: could not load 'kcl.mod' in '<workspace>'
2-
error: open <workspace>/kcl.mod: no such file or directory
1+
could not load 'kcl.mod' in '<workspace>'
2+
open <workspace>/kcl.mod: no such file or directory
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
error: could not load 'kcl.mod' in '<workspace>'
2-
error: open <workspace>/kcl.mod: no such file or directory
1+
could not load 'kcl.mod' in '<workspace>'
2+
open <workspace>/kcl.mod: no such file or directory
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
error: oci url or package name must be specified
2-
error: failed to pull kcl package
1+
oci url or package name must be specified
2+
failed to pull kcl package
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
error: oci url or package name must be specified
2-
error: failed to pull kcl package
1+
oci url or package name must be specified
2+
failed to pull kcl package
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
error: only support url scheme 'oci://'
2-
error: invalid oci url
1+
only support url scheme 'oci://'
2+
invalid oci url
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
error: failed to login 'ghcr.io', please check registry, username and password is valid
2-
error: Get "https://ghcr.io/v2/": unsupported
1+
failed to login 'ghcr.io', please check registry, username and password is valid
2+
Get "https://ghcr.io/v2/": unsupported
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
error: registry must be specified
1+
registry must be specified
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
error: failed to logout 'invalid_registry'
2-
error: not logged in
1+
failed to logout 'invalid_registry'
2+
not logged in
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
error: registry must be specified
1+
registry must be specified
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
error: failed to get package with 'invalid_tag' from 'localhost:5001/test/invalid_oci_repo'
2-
error: failed to resolve invalid_tag: localhost:5001/test/invalid_oci_repo:invalid_tag: not found
1+
failed to get package with 'invalid_tag' from 'localhost:5001/test/invalid_oci_repo'
2+
failed to resolve invalid_tag: localhost:5001/test/invalid_oci_repo:invalid_tag: not found
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
error: repository 'invalid_url/' not found
2-
error: invalid reference: invalid repository
1+
repository 'invalid_url/' not found
2+
invalid reference: invalid repository
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
error: repository 'invalid_rul/' not found
2-
error: invalid reference: invalid repository
1+
repository 'invalid_rul/' not found
2+
invalid reference: invalid repository
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
error: could not load 'kcl.mod' in '<workspace>'
2-
error: open <workspace>/kcl.mod: no such file or directory
1+
could not load 'kcl.mod' in '<workspace>'
2+
open <workspace>/kcl.mod: no such file or directory
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
error: failed to compile the kcl package
2-
error: Cannot find the kcl file, please check the file path
1+
failed to compile the kcl package
2+
Cannot find the kcl file, please check the file path
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
error: could not load 'kcl.mod' in '<workspace>'
2-
error: open <workspace>/kcl.mod: no such file or directory
1+
could not load 'kcl.mod' in '<workspace>'
2+
open <workspace>/kcl.mod: no such file or directory
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
error: oci url must be specified
1+
oci url must be specified
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
error: only allows one package to be compiled at a time
2-
error: cannot compile multiple packages [<workspace>/test_kpm_run_with_multi_kfile_1 <workspace>/test_kpm_run_with_multi_kfile_1/sub] at the same time
1+
only allows one package to be compiled at a time
2+
cannot compile multiple packages [<workspace>/test_kpm_run_with_multi_kfile_1 <workspace>/test_kpm_run_with_multi_kfile_1/sub] at the same time
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
error: only allows one package to be compiled at a time
2-
error: cannot compile multiple packages [<workspace>/test_kpm_run_with_multi_pkg/kcl1 <workspace>/test_kpm_run_with_multi_pkg/kcl2] at the same time
1+
only allows one package to be compiled at a time
2+
cannot compile multiple packages [<workspace>/test_kpm_run_with_multi_pkg/kcl1 <workspace>/test_kpm_run_with_multi_pkg/kcl2] at the same time
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
error: only allows one package to be compiled at a time
2-
error: cannot compile multiple packages [<workspace>/test_kpm_run_with_multi_pkg_1/kcl1 <workspace>/test_kpm_run_with_multi_pkg_1/kcl2 oci://kcl-lang/kcl] at the same time
1+
only allows one package to be compiled at a time
2+
cannot compile multiple packages [<workspace>/test_kpm_run_with_multi_pkg_1/kcl1 <workspace>/test_kpm_run_with_multi_pkg_1/kcl2 oci://kcl-lang/kcl] at the same time

0 commit comments

Comments
 (0)