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

The recv function of void functions doesn't throw custom exceptions

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 0.12.0
    • None
    • Lua - Compiler
    • None

    Description

      In thrift/compiler/cpp/src/thrift/generate/t_lua_generator.cc:621, it only throws custom exceptions when the function is not void. However, void function could still return exceptions to the caller service, as long as the function is not oneway.

      // Return the result if it's not a void function
            if (!(*f_iter)->get_returntype()->is_void()) {
              out << indent() << "if result.success ~= nil then" << endl << indent() << "  return result.success"
                  << endl;
      
              // Throw custom exceptions
              const std::vector<t_field*>& xf = (*f_iter)->get_xceptions()->get_members();
              vector<t_field*>::const_iterator x_iter;
              for (x_iter = xf.begin(); x_iter != xf.end(); ++x_iter) {
                out << indent() << "elseif result." << (*x_iter)->get_name() << " then" << endl
                    << indent() << "  error(result." << (*x_iter)->get_name() << ")" << endl;
              }
      
              out << indent() << "end" << endl << indent()
                  << "error(TApplicationException:new{errorCode = "
                  << "TApplicationException.MISSING_RESULT})" << endl;
            }
      
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            gy1005 Yu Gan
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: