From: Bryan Duxbury Date: Wed, 18 Mar 2009 01:50:50 +0000 (+0000) Subject: THRIFT-278. java: #validate exceptions should contain the offending value X-Git-Tag: 0.2.0~263 X-Git-Url: https://source.supwisdom.com/gerrit/gitweb?a=commitdiff_plain;h=97592b40b1ae6d00911ab5e76dd951b011c63863;p=common%2Fthrift.git 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. git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@755454 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/compiler/cpp/src/generate/t_java_generator.cc b/compiler/cpp/src/generate/t_java_generator.cc index abbba8b8..442488e1 100644 --- a/compiler/cpp/src/generate/t_java_generator.cc +++ b/compiler/cpp/src/generate/t_java_generator.cc @@ -1043,9 +1043,9 @@ void t_java_generator::generate_java_validator(ofstream& out, 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; }