Skip to content

Commit 527f21c

Browse files
committed
fix: replace panic with log.Fatal in grpc-smoke-client
Use idiomatic log.Fatal/log.Fatalf instead of panic for CLI error handling in the smoke test tool.
1 parent 86a7837 commit 527f21c

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

cmd/grpc-smoke-client/main.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"errors"
77
"flag"
88
"fmt"
9+
"log"
910
"math"
1011
"os"
1112
"sort"
@@ -59,10 +60,10 @@ func main() {
5960
flag.Parse()
6061

6162
if *requests < 1 {
62-
panic("requests must be >= 1")
63+
log.Fatal("requests must be >= 1")
6364
}
6465
if *concurrency < 1 {
65-
panic("concurrency must be >= 1")
66+
log.Fatal("concurrency must be >= 1")
6667
}
6768

6869
conn, err := grpc.NewClient(
@@ -71,7 +72,7 @@ func main() {
7172
grpc.WithAuthority(*authority),
7273
)
7374
if err != nil {
74-
panic(fmt.Errorf("create grpc client: %w", err))
75+
log.Fatalf("create grpc client: %v", err)
7576
}
7677
defer conn.Close()
7778

@@ -80,14 +81,14 @@ func main() {
8081

8182
if !*jsonOutput && *requests == 1 && *concurrency == 1 {
8283
if summary.Successes != 1 {
83-
panic(fmt.Errorf("invoke grpc method %s via %s: %s", *method, *addr, results[0].Error))
84+
log.Fatalf("invoke grpc method %s via %s: %s", *method, *addr, results[0].Error)
8485
}
8586
fmt.Println("grpc smoke ok")
8687
return
8788
}
8889

8990
if err := json.NewEncoder(os.Stdout).Encode(summary); err != nil {
90-
panic(fmt.Errorf("encode summary: %w", err))
91+
log.Fatalf("encode summary: %v", err)
9192
}
9293

9394
if summary.Successes != summary.Completed {

0 commit comments

Comments
 (0)