Skip to content

Commit 0385be3

Browse files
committed
add error handling for the SubscribeTopics function call
1 parent cb2701e commit 0385be3

File tree

6 files changed

+24
-0
lines changed

6 files changed

+24
-0
lines changed

examples/avro_generic_consumer_example/avro_generic_consumer_example.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ func main() {
7575
}
7676

7777
err = c.SubscribeTopics(topics, nil)
78+
if err != nil {
79+
fmt.Fprintf(os.Stderr, "Failed to subscribe to topics: %v\n", err)
80+
os.Exit(1)
81+
}
7882

7983
run := true
8084

examples/avro_specific_consumer_example/avro_specific_consumer_example.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ func main() {
7575
}
7676

7777
err = c.SubscribeTopics(topics, nil)
78+
if err != nil {
79+
fmt.Fprintf(os.Stderr, "Failed to subscribe to topics: %v\n", err)
80+
os.Exit(1)
81+
}
7882

7983
run := true
8084

examples/consumer_example/consumer_example.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ func main() {
6969
fmt.Printf("Created Consumer %v\n", c)
7070

7171
err = c.SubscribeTopics(topics, nil)
72+
if err != nil {
73+
fmt.Fprintf(os.Stderr, "Failed to subscribe to topics: %v\n", err)
74+
os.Exit(1)
75+
}
7276

7377
run := true
7478

examples/json_consumer_example/json_consumer_example.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ func main() {
7575
}
7676

7777
err = c.SubscribeTopics(topics, nil)
78+
if err != nil {
79+
fmt.Fprintf(os.Stderr, "Failed to subscribe to topics: %v\n", err)
80+
os.Exit(1)
81+
}
7882

7983
run := true
8084

examples/protobuf_consumer_example/protobuf_consumer_example.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@ func main() {
8080
deser.ProtoRegistry.RegisterMessage((&User{}).ProtoReflect().Type())
8181

8282
err = c.SubscribeTopics(topics, nil)
83+
if err != nil {
84+
fmt.Fprintf(os.Stderr, "Failed to subscribe to topics: %v\n", err)
85+
os.Exit(1)
86+
}
8387

8488
run := true
8589

examples/stats_example/stats_example.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ func main() {
6363
fmt.Printf("Created Consumer %v\n", c)
6464

6565
err = c.SubscribeTopics(topics, nil)
66+
if err != nil {
67+
fmt.Fprintf(os.Stderr, "Failed to subscribe to topics: %v\n", err)
68+
os.Exit(1)
69+
}
6670

6771
run := true
6872

0 commit comments

Comments
 (0)