justinmclean commented on code in PR #6573:
URL: https://github.com/apache/gravitino/pull/6573#discussion_r1976528789


##########
clients/cli/src/main/java/org/apache/gravitino/cli/commands/TopicDetails.java:
##########
@@ -58,24 +58,27 @@ public TopicDetails(
   /** Displays the details of a topic. */
   @Override
   public void handle() {
-    Topic gTopic = null;
-
-    try {
+    try (GravitinoClient client = buildClient(metalake)) {
       NameIdentifier name = NameIdentifier.of(schema, topic);
-      GravitinoClient client = buildClient(metalake);
-      gTopic = client.loadCatalog(catalog).asTopicCatalog().loadTopic(name);
-    } catch (NoSuchMetalakeException err) {
+      Topic gTopic = 
client.loadCatalog(catalog).asTopicCatalog().loadTopic(name);
+
+      if (gTopic == null) {
+        exitWithError(ErrorMessages.UNKNOWN_TOPIC);
+        return;
+      }
+
+      printResults("Topic Name: " + gTopic.name() + ", Comment: " + 
gTopic.comment());
+
+    } catch (NoSuchMetalakeException e) {
       exitWithError(ErrorMessages.UNKNOWN_METALAKE);
-    } catch (NoSuchCatalogException err) {
+    } catch (NoSuchCatalogException e) {
       exitWithError(ErrorMessages.UNKNOWN_CATALOG);
-    } catch (NoSuchSchemaException err) {
+    } catch (NoSuchSchemaException e) {
       exitWithError(ErrorMessages.UNKNOWN_SCHEMA);
-    } catch (NoSuchTopicException err) {
+    } catch (NoSuchTopicException e) {
       exitWithError(ErrorMessages.UNKNOWN_TOPIC);
-    } catch (Exception exp) {
-      exitWithError(exp.getMessage());
+    } catch (Exception e) {
+      exitWithError("Error retrieving topic details: " + e.getMessage());

Review Comment:
   Please don't make unnessacary changes to the code.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to