ArafatKhan2198 commented on code in PR #6651:
URL: https://github.com/apache/ozone/pull/6651#discussion_r1595584774


##########
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/admin/scm/ResetDeletedBlockRetryCountSubcommand.java:
##########
@@ -92,9 +90,12 @@ public void execute(ScmClient client) throws IOException {
           System.out.println("The last loaded txID: " +
               txIDs.get(txIDs.size() - 1));
         }
-      } catch (JsonIOException | JsonSyntaxException | IOException ex) {
-        System.out.println("Cannot parse the file " + group.fileName);
+      } catch (JsonProcessingException ex) {
+        System.out.println("Error parsing JSON: " + ex.getMessage());
         throw new IOException(ex);
+      } catch (IOException ex) {
+        System.out.println("Error reading file: " + ex.getMessage());
+        throw ex;

Review Comment:
   Thanks I have made the changes to the following :- 
   
   ```
   } catch (JsonProcessingException ex) {
     final String message = "Failed to parse the file " + group.fileName;
     System.out.println(message);
     throw new IOException(message, ex);
   } catch (IOException ex) {
     System.out.println("Error reading file: " + ex.getMessage());
     throw ex;
   }
   ```
   
   I did try to put both the error messages in a single catch but got the error 
message saying that the types in your multi-catch statement are not disjoint.  
In this case, **`com.fasterxml.jackson.core.JsonProcessingException is a 
subclass of java.io.IOException,`** which is causing the issue.
   To resolve this, I separated the catch blocks for JsonProcessingException 
and IOException. 
   This way, the catch blocks handle the exceptions separately, and we can 
include the file name in the error message for the `JsonProcessingException` 
catch block.
   
   
   
   
   
   
   



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to