Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8277323

Simplified Exception Wrapper

XMLWordPrintable

    • generic
    • generic

      A DESCRIPTION OF THE PROBLEM :
      Please check below code snippet,
      public void doSomething() throws AIProcessingException {
      try {
                  sentimentClassification();
              } catch (InterruptedException | ExecutionException e) {
                  throw new AIProcessingException(e);
              }
      }
      If we do not catch InterruptedException, ExecutionException, we need to declare it on method signature.
      But we don't want business code caller to handle these two exceptions, so we need to wrap it by business exception.
      But similar code exist everywhere, which made the code not elegant.
      Could we add a mechanism that wrapping up exceptions automatically by method declaration?
      For example,
      public void doSomething() throws AIProcessingException[InterruptedException, ExecutionException]

      In this way, the method implementation would be simplified to:
       public void doSomething() throws AIProcessingException[InterruptedException, ExecutionException] {
             sentimentClassification();
      }


            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: