Skip to content

Commit aed97c4

Browse files
authored
Merge pull request #1257 from ActiveState/dgreen/localize_clean_cache_err-176827634
Remove errors.New+locale.T usage
2 parents 4f56f30 + 9f1dc93 commit aed97c4

6 files changed

Lines changed: 7 additions & 13 deletions

File tree

internal/prompt/helpers.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package prompt
22

33
import (
4-
"errors"
54
"math"
65
"reflect"
76
"strings"
@@ -53,7 +52,7 @@ func inputRequired(val interface{}) error {
5352

5453
// if the value passed in is the zero value of the appropriate type
5554
if isZero(value) && value.Kind() != reflect.Bool && value.Kind() != reflect.Int {
56-
return errors.New(locale.T("err_value_required"))
55+
return locale.NewError("err_value_required")
5756
}
5857
return nil
5958
}

internal/runners/clean/cache.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package clean
22

33
import (
4-
"errors"
54
"os"
65

76
"github.com/ActiveState/cli/internal/config"
@@ -42,7 +41,7 @@ func newCache(output output.Outputer, cfg configurable, confirm confirmAble) *Ca
4241

4342
func (c *Cache) Run(params *CacheParams) error {
4443
if os.Getenv(constants.ActivatedStateEnvVarName) != "" {
45-
return errors.New(locale.T("err_clean_cache_activated"))
44+
return locale.NewError("err_clean_cache_activated")
4645
}
4746

4847
if params.Project != "" {

internal/runners/clean/config.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package clean
22

33
import (
4-
"errors"
54
"os"
65

76
"github.com/ActiveState/cli/internal/constants"
@@ -42,7 +41,7 @@ func newConfig(out output.Outputer, confirm confirmAble, cfg configurable) *Conf
4241

4342
func (c *Config) Run(params *ConfigParams) error {
4443
if os.Getenv(constants.ActivatedStateEnvVarName) != "" {
45-
return errors.New(locale.T("err_clean_cache_activated"))
44+
return locale.NewError("err_clean_cache_activated")
4645
}
4746

4847
if !params.Force {

internal/runners/clean/uninstall.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package clean
22

33
import (
4-
"errors"
54
"os"
65

76
"github.com/ActiveState/cli/internal/constants"
@@ -51,7 +50,7 @@ func newUninstall(out output.Outputer, confirm confirmAble, cfg configurable) (*
5150

5251
func (u *Uninstall) Run(params *UninstallParams) error {
5352
if os.Getenv(constants.ActivatedStateEnvVarName) != "" {
54-
return errors.New(locale.T("err_uninstall_activated"))
53+
return locale.NewError("err_uninstall_activated")
5554
}
5655

5756
if !params.Force {

internal/runners/languages/install.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package languages
22

33
import (
4-
"errors"
54
"strings"
65

76
"github.com/ActiveState/cli/internal/locale"
@@ -85,7 +84,7 @@ func parseLanguage(langName string) (*model.Language, error) {
8584

8685
split := strings.Split(langName, "@")
8786
if len(split) != 2 {
88-
return nil, errors.New(locale.T("err_language_format"))
87+
return nil, locale.NewError("err_language_format")
8988
}
9089
name := split[0]
9190
version := split[1]
@@ -108,7 +107,7 @@ func ensureLanguagePlatform(language *model.Language) error {
108107
}
109108
}
110109

111-
return errors.New(locale.Tr("err_update_not_found", language.Name))
110+
return locale.NewError("err_update_not_found", language.Name)
112111
}
113112

114113
func ensureLanguageProject(language *model.Language, project *project.Project) error {

pkg/cmdlets/auth/signup.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package auth
22

33
import (
4-
"errors"
54
"io"
65
"io/ioutil"
76
"net/http"
@@ -234,7 +233,7 @@ func UsernameValidator(val interface{}) error {
234233
params.SetUsername(value)
235234
res, err := mono.Get().Users.UniqueUsername(params)
236235
if err != nil || *res.Payload.Code != int64(200) {
237-
return errors.New(locale.T("err_username_taken"))
236+
return locale.NewError("err_username_taken")
238237
}
239238
return nil
240239
}

0 commit comments

Comments
 (0)