Author: bryanduxbury
Date: Wed Mar 18 01:50:50 2009
New Revision: 755454
URL: http://svn.apache.org/viewvc?rev=755454&view=rev
Log:
THRIFT-278. java: #validate exceptions should contain the offending value
This patch causes validate to throw exceptions that contain the bad field value
as well as the field name. I had to modify it slightly from the patch on the
issue to conform with the new style isset checks.
Modified:
incubator/thrift/trunk/compiler/cpp/src/generate/t_java_generator.cc
Modified: incubator/thrift/trunk/compiler/cpp/src/generate/t_java_generator.cc
URL:
http://svn.apache.org/viewvc/incubator/thrift/trunk/compiler/cpp/src/generate/t_java_generator.cc?rev=755454&r1=755453&r2=755454&view=diff
==============================================================================
--- incubator/thrift/trunk/compiler/cpp/src/generate/t_java_generator.cc
(original)
+++ incubator/thrift/trunk/compiler/cpp/src/generate/t_java_generator.cc Wed
Mar 18 01:50:50 2009
@@ -1043,9 +1043,9 @@
package = program->get_namespace("java") + ".";
}
- indent(out) << "if (__isset." << field->get_name() << " && !" << package
<< type->get_name() << ".VALID_VALUES.contains(" << field->get_name() << ")){"
<< endl;
+ indent(out) << "if (" << generate_isset_check(field) << " && !" <<
package << type->get_name() << ".VALID_VALUES.contains(" << field->get_name()
<< ")){" << endl;
indent_up();
- indent(out) << "throw new TProtocolException(\"Invalid value of field '"
<< field->get_name() << "'!\");" << endl;
+ indent(out) << "throw new TProtocolException(\"The field '" <<
field->get_name() << "' has been assigned the invalid value \" + " <<
field->get_name() << ");" << endl;
indent_down();
indent(out) << "}" << endl;
}