Skip to content

Commit 537e821

Browse files
authored
AWS region error links to docs (#859)
* added link to docs on aws region error * fix proto to pass test
1 parent 5999d53 commit 537e821

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/pkg/cli/client/byoc/aws/byoc.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,18 @@ func (e ErrMissingAwsCreds) Unwrap() error {
7474
return e.err
7575
}
7676

77+
type ErrMissingAwsRegion struct {
78+
err error
79+
}
80+
81+
func (e ErrMissingAwsRegion) Error() string {
82+
return "missing AWS region: set AWS_REGION or edit your AWS profile (https://docs.defang.io/docs/providers/aws#region)"
83+
}
84+
85+
func (e ErrMissingAwsRegion) Unwrap() error {
86+
return e.err
87+
}
88+
7789
func AnnotateAwsError(err error) error {
7890
if err == nil {
7991
return nil
@@ -82,6 +94,9 @@ func AnnotateAwsError(err error) error {
8294
if strings.Contains(err.Error(), "get credentials:") {
8395
return connect.NewError(connect.CodeUnauthenticated, ErrMissingAwsCreds{err})
8496
}
97+
if strings.Contains(err.Error(), "missing AWS region:") {
98+
return connect.NewError(connect.CodeUnauthenticated, ErrMissingAwsRegion{err})
99+
}
85100
if cerr := new(aws.ErrNoSuchKey); errors.As(err, &cerr) {
86101
return connect.NewError(connect.CodeNotFound, err)
87102
}

0 commit comments

Comments
 (0)