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

All exceptions are TException

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Cannot Reproduce
    • 0.13.0
    • None
    • C++ - Library
    • None

    Description

      In recent versions of thrift we can not catch exceptions based on their IDL type anymore. I'm not sure if we broke something, but the code is sufficiently simple to suggest a bug in thrift. So here is what we have:

      1. A method with signature that can throw a specific exception, i.e. UserException
      2. The C++ server throws this exception whenever the method is called
      3. The C++ client tries to catch this exception but it passes through

      The client can catch the exception as `TException` or as `std::exception` and we can see from the printed message `vException.what()` that its a `UserException`. But catch does not deduce the type correctly.

      Here is the part of the catch that does not work:

      try {
          vClient->SendRequest();
      } catch (const MyService::UserException& vEx) {
          // Why is this not caught, when the server throws MyService::UserException?
          std::cerr << "Caught a UserException, message " << vEx.what() << std::endl;
      } catch (const std::exception& vEx) {
          // Why is this one called instead?
          std::cerr << "Caught a std::exception, message " << vEx.what() << std::endl;
      }
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            emmenlau Mario Emmenlauer
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: