For Thrift exceptions that contain only a single string field, integrate
these even more tightly with Ruby exceptions by aliasing Ruby's
Exception#message field with the Thrift field.
Ruby exception objects created by Thrift will now display properly in
Ruby backtraces, etc. without any special handling by client code.
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665503
13f79535-47bb-0310-9956-
ffa450edef68
vector<t_field*>::const_iterator m_iter = members.begin();
if ((*m_iter)->get_type()->is_string()) {
+ string name = (*m_iter)->get_name();
+
indent(out) << "def initialize(message=nil)" << endl;
indent_up();
indent(out) << "super()" << endl;
- indent(out) << "self." << (*m_iter)->get_name() << " = message" << endl;
+ indent(out) << "self." << name << " = message" << endl;
indent_down();
indent(out) << "end" << endl << endl;
+
+ if (name != "message") {
+ indent(out) << "def message; " << name << " end" << endl << endl;
+ }
}
}
}