Skip to content

Commit

Permalink
Add error handling for SubscribeTopics function call
Browse files Browse the repository at this point in the history
This commit adds error handling to the main function in consumer_example.go file. Specifically, it checks for errors returned by the SubscribeTopics function call and exits the program with an error message if the subscription fails. This ensures robustness and graceful handling of errors during topic subscription.
  • Loading branch information
Vrashabh-Sontakke authored Apr 9, 2024
1 parent cb2701e commit b72301c
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions examples/consumer_example/consumer_example.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ func main() {

err = c.SubscribeTopics(topics, nil)

if err != nil {
fmt.Fprintf(os.Stderr, "Failed to subscribe to topics: %v\n", err)
os.Exit(1)
}

run := true

for run {
Expand Down

0 comments on commit b72301c

Please sign in to comment.