Skip to content

Commit 9141d96

Browse files
author
Xu Ao
committed
Correct error handling
1 parent c91990d commit 9141d96

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

main.go

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

33
import (
4+
"errors"
45
"fmt"
56
"os"
67
"os/signal"
@@ -213,13 +214,14 @@ func main() {
213214
},
214215
},
215216
Action: func(c *cli.Context) error {
216-
if !((accessKeyID == "" && secretAccessKey == "") || (accessKeyID != "" && secretAccessKey != "")){
217-
fmt.Println("Must provide access key id and secret access key at the same time")
218-
} else {
219-
db.GetDynamoSession(accessKeyID, secretAccessKey, region)
217+
if !((accessKeyID == "" && secretAccessKey == "") || (accessKeyID != "" && secretAccessKey != "")) {
218+
return errors.New("Must provide access key id and secret access key at the same time")
219+
} else if _, err := db.GetDynamoSession(accessKeyID, secretAccessKey, region); err == nil {
220220
runPrompt(tablePrefix)
221+
return nil
222+
} else {
223+
return err
221224
}
222-
return nil
223225
},
224226
}
225227

0 commit comments

Comments
 (0)