Skip to content

Commit

Permalink
handle missing region
Browse files Browse the repository at this point in the history
  • Loading branch information
thdxr committed Dec 22, 2023
1 parent f918698 commit 716106b
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
7 changes: 6 additions & 1 deletion cmd/sst/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/manifoldco/promptui"

"github.com/sst/ion/cmd/sst/ui"
"github.com/sst/ion/internal/util"
"github.com/sst/ion/pkg/global"
"github.com/sst/ion/pkg/project"

Expand Down Expand Up @@ -260,7 +261,11 @@ func main() {

err := app.Run(os.Args)
if err != nil {
panic(err)
if err, ok := err.(*util.ReadableError); ok {
fmt.Println(err.Message)
} else {
panic(err)
}
}

}
Expand Down
1 change: 0 additions & 1 deletion examples/test/sst.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ export default $config({
app(input) {
return {
name: "test",
region: "us-east-1",
removalPolicy: "remove",
providers: {
aws: {
Expand Down
12 changes: 12 additions & 0 deletions internal/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,15 @@ func RandomString(length int) string {
}
return string(b)
}

type ReadableError struct {
Message string
}

func NewReadableError(message string) *ReadableError {
return &ReadableError{Message: message}
}

func (e *ReadableError) Error() string {
return e.Message
}
3 changes: 3 additions & 0 deletions pkg/project/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,9 @@ func (a *AwsProvider) Init(workdir string, args map[string]string) (err error) {
if err != nil {
return err
}
if cfg.Region == "" {
return util.NewReadableError("No region found in AWS config")
}
a.config = cfg

bucket, err := a.resolveBucket()
Expand Down

0 comments on commit 716106b

Please sign in to comment.