From d180c70152426cb13606d03d610874a01e6a2c07 Mon Sep 17 00:00:00 2001 From: mitchell Date: Mon, 28 Oct 2024 17:43:39 -0400 Subject: [PATCH 1/2] Localize an access denied error when attempting to migrate an activestate.yaml. --- pkg/projectfile/yamlfield.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pkg/projectfile/yamlfield.go b/pkg/projectfile/yamlfield.go index 2217d37a4b..48d829018f 100644 --- a/pkg/projectfile/yamlfield.go +++ b/pkg/projectfile/yamlfield.go @@ -7,6 +7,8 @@ import ( "regexp" "github.com/ActiveState/cli/internal/errs" + "github.com/ActiveState/cli/internal/locale" + "github.com/ActiveState/cli/internal/osutils" "gopkg.in/yaml.v2" ) @@ -56,6 +58,11 @@ func (y *yamlField) Save(path string) error { } if err := os.WriteFile(path, out, 0664); err != nil { + if osutils.IsAccessDeniedError(err) { + return locale.WrapError(err, "err_migrate_projectfile_access_denied", + "Your project file at '{{.V0}}' is out of date, but State Tool does not have permission to update it. Please make it writeable or re-checkout the project to a writeable location.", + path) + } return errs.Wrap(err, "ioutil.WriteFile %s failed", path) } From 6fba38b4b4705742f2f1d1f0d143fb980c41e646 Mon Sep 17 00:00:00 2001 From: mitchell Date: Wed, 30 Oct 2024 13:03:59 -0400 Subject: [PATCH 2/2] Make access denied error an input error. --- pkg/projectfile/yamlfield.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/projectfile/yamlfield.go b/pkg/projectfile/yamlfield.go index 48d829018f..13b5691530 100644 --- a/pkg/projectfile/yamlfield.go +++ b/pkg/projectfile/yamlfield.go @@ -59,7 +59,7 @@ func (y *yamlField) Save(path string) error { if err := os.WriteFile(path, out, 0664); err != nil { if osutils.IsAccessDeniedError(err) { - return locale.WrapError(err, "err_migrate_projectfile_access_denied", + return locale.WrapInputError(err, "err_migrate_projectfile_access_denied", "Your project file at '{{.V0}}' is out of date, but State Tool does not have permission to update it. Please make it writeable or re-checkout the project to a writeable location.", path) }