From 31f7da1e223d2b0bf136bd8c32bb2159d6d2abe9 Mon Sep 17 00:00:00 2001 From: Vrashabh Sontakke <86019029+Vrashabh-Sontakke@users.noreply.github.com> Date: Fri, 5 Apr 2024 21:34:23 +0530 Subject: [PATCH 1/2] 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 | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/examples/consumer_example/consumer_example.go b/examples/consumer_example/consumer_example.go index 60dfdfaef..45aab8f92 100644 --- a/examples/consumer_example/consumer_example.go +++ b/examples/consumer_example/consumer_example.go @@ -69,6 +69,10 @@ func main() { fmt.Printf("Created Consumer %v\n", c) 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 From 9f5dbd0436fbfd437ac09940df03044e8ba95ad8 Mon Sep 17 00:00:00 2001 From: Vrashabh Sontakke <86019029+Vrashabh-Sontakke@users.noreply.github.com> Date: Fri, 5 Apr 2024 21:50:02 +0530 Subject: [PATCH 2/2] fix: Correct indentation in consumer_example.go Adjusted indentation for improved readability and consistency. --- examples/consumer_example/consumer_example.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/consumer_example/consumer_example.go b/examples/consumer_example/consumer_example.go index 45aab8f92..1f1a7262d 100644 --- a/examples/consumer_example/consumer_example.go +++ b/examples/consumer_example/consumer_example.go @@ -70,8 +70,8 @@ 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) + fmt.Fprintf(os.Stderr, "Failed to subscribe to topics: %v\n", err) + os.Exit(1) } run := true