Ruby exception constructor bugfix
authorDavid Reiss <dreiss@apache.org>
Tue, 26 Feb 2008 06:40:16 +0000 (06:40 +0000)
committerDavid Reiss <dreiss@apache.org>
Tue, 26 Feb 2008 06:40:16 +0000 (06:40 +0000)
The Ruby exception constructor is modified to accept 0 arguments, which is
how Thrift library code creates exception objects. Without this fix, Thrift
Ruby clients that receive exception objects crash.

The call to super (resolving to ThriftStruct#initialize) is retained, but
is called with the default value (an empty hash) instead of passing the
message along.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665501 13f79535-47bb-0310-9956-ffa450edef68

compiler/cpp/src/generate/t_rb_generator.cc

index 1e2fa7d..220a3de 100644 (file)
@@ -318,9 +318,9 @@ void t_rb_generator::generate_rb_simple_exception_constructor(std::ofstream& out
     vector<t_field*>::const_iterator m_iter = members.begin();
 
     if ((*m_iter)->get_type()->is_string()) {
-      indent(out) << "def initialize(message)" << endl;
+      indent(out) << "def initialize(message=nil)" << endl;
       indent_up();
-      indent(out) << "super(message)" << endl;
+      indent(out) << "super()" << endl;
       indent(out) << "self." << (*m_iter)->get_name() << " = message" << endl;
       indent_down();
       indent(out) << "end" << endl << endl;