code: private static void printException(Exception e) {
  
          if (e instanceof InstallationCancelledException) {
              System.out.println("Installation cancelled.");
              return;
          }
  
          boolean recognized = false;
          String msg = "ERROR: ";
          if (e instanceof InstallationFailedException) {
              msg += "Installation failed: " + e.getMessage();
              recognized = true;
          } else if (e instanceof OptionValidationException) {
              OptionValidationException ove = (OptionValidationException) e;
              msg +=
                      "Bad value for '" + ove.getOptionId() + "': "
                              + e.getMessage();
              recognized = true;
          }
  
          if (recognized) {
              System.err.println(msg);
              if (e.getCause() != null) {
                  System.err.println("Caused by: ");
                  e.getCause().printStackTrace(System.err);
              }
          } else {
              System.err.println(msg + "Unexpected error; installation aborted.");
              e.printStackTrace();
          }
      }
docs: Print a message appropriate for the given exception in as human-readable
  way as possible.