From b72301cecb09e007f2286f5d25d9f6559057a191 Mon Sep 17 00:00:00 2001 From: Vrashabh Sontakke <86019029+Vrashabh-Sontakke@users.noreply.github.com> Date: Tue, 9 Apr 2024 19:28:51 +0530 Subject: [PATCH] Add error handling for SubscribeTopics function call 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. --- examples/consumer_example/consumer_example.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/examples/consumer_example/consumer_example.go b/examples/consumer_example/consumer_example.go index 60dfdfaef..b3f21f75d 100644 --- a/examples/consumer_example/consumer_example.go +++ b/examples/consumer_example/consumer_example.go @@ -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 {