Uploaded image for project: 'Thrift'
  1. Thrift
  2. THRIFT-2935

Exceptions in Java code should not extends TException

    Details

      Description

      Exceptions in Java should not extend TException to avoid collisions on method signature for better IDE support. Currently, if service is throwing some thrift exception, i.e. TMyCustomException, it will have following signature:

      public void myMethod() throws TMyCustomException, TException {
      }

      But TMyCustomException is overlapped by TException,

      Now, if we will call this method in our code:

      client.myMethod();

      IDE will propose to generate try\catch with only 1 block:

      try {
      client.myMethod();
      } catch(TException e) {
      }

      Because TMyCustomException extends TException. If TMyCustomException will extends just Exception, than IDE will generate following code:

      try {
      client.myMethod();
      } catch(TMyCustomException e) {
      } catch(TException e) {
      }

      which is much better, because client caller will know about any custom thrift exception in this method.

      Thanks!

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                bsideup Sergei Egorov
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated: