Skip to content

Commit 635538c

Browse files
authored
update error message when configuration fails (#186)
1 parent a4cf2d2 commit 635538c

File tree

3 files changed

+10
-11
lines changed

3 files changed

+10
-11
lines changed

CHANGELOG.md

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

33
### Master
44

5+
- update error message when configuration fails
56
- Forced calls to support different API styles
67

78
### 3.0.16

config/hello.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,14 @@ func DoHello(ctx *cli.Context, profile *Profile) {
6565
err = client.DoAction(request, response)
6666

6767
if err != nil {
68-
panic(err)
69-
}
70-
cli.Printf(w, " available regions: \n")
71-
for _, region := range response.Regions.Region {
72-
cli.Printf(w, " %s\n", region.RegionId)
68+
cli.Println(w, "-----------------------------------------------")
69+
cli.Println(w, "!!! Configure Failed please configure again !!!")
70+
cli.Println(w, "-----------------------------------------------")
71+
cli.Println(w, err)
72+
cli.Println(w, "-----------------------------------------------")
73+
cli.Println(w, "!!! Configure Failed please configure again !!!")
74+
cli.Println(w, "-----------------------------------------------")
75+
return
7376
}
7477
fmt.Println(icon)
7578
}

config/hello_test.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,6 @@ func TestDoHello(t *testing.T) {
5454
profile.AccessKeyId = "AccessKeyId"
5555
profile.AccessKeySecret = "AccessKeySecret"
5656
profile.RegionId = "cn-hangzhou"
57-
defer func() {
58-
err := recover()
59-
assert.NotNil(t, err)
60-
61-
}()
6257
DoHello(ctx, &profile)
63-
assert.True(t, strings.Contains(w.String(), "vender/cli_test_VendorTest"))
58+
assert.True(t, strings.Contains(w.String(), "-----------------------------------------------\n!!! Configure Failed please configure again !!!\n-----------------------------------------------"))
6459
}

0 commit comments

Comments
 (0)