duongnguyen0 commented on code in PR #3517:
URL: https://github.com/apache/ozone/pull/3517#discussion_r899809242


##########
hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/cli/GenericCli.java:
##########
@@ -52,6 +53,10 @@ public class GenericCli implements Callable<Void>, 
GenericParentCommand {
 
   public GenericCli() {
     cmd = new CommandLine(this);
+    cmd.setExecutionExceptionHandler((ex, commandLine, parseResult) -> {
+      printError(ex);

Review Comment:
   Thanks for the thorough review @rakeshadr. 
   Indeed, the extraction of the ExecutionException's cause happens in the 
caller of ExecutionExceptionHandler, aka. `CommandLine.execute`.
   
   ```
       public int execute(String... args) {
           
           try {
               parseResult[0] = parseArgs(args);
               return 
enrichForBackwardsCompatibility(getExecutionStrategy()).execute(parseResult[0]);
           } catch (ParameterException ex) {
               ...
           } catch (ExecutionException ex) {
               try {
                   Exception cause = ex.getCause() instanceof Exception ? 
(Exception) ex.getCause() : ex;
                   return 
getExecutionExceptionHandler().handleExecutionException(cause, 
ex.getCommandLine(), parseResult[0]);
               } ....
       }
   ```
   
   Basically, the same printed error message is maintained. And I did a 
comparison to verify it and put a sample in the PR's description.



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