[Rprotobuf-commits] r528 - in pkg: . src

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sat Sep 7 08:46:57 CEST 2013


Author: murray
Date: 2013-09-07 08:46:57 +0200 (Sat, 07 Sep 2013)
New Revision: 528

Modified:
   pkg/ChangeLog
   pkg/src/rprotobuf.cpp
Log:
Include the field name in error messages from new, update, etc, when a
field descriptor can't be found.



Modified: pkg/ChangeLog
===================================================================
--- pkg/ChangeLog	2013-09-04 00:38:59 UTC (rev 527)
+++ pkg/ChangeLog	2013-09-07 06:46:57 UTC (rev 528)
@@ -1,3 +1,9 @@
+2013-09-06  Murray Stokely  <murray at FreeBSD.org>
+
+	* src/rprotobuf.cpp (rprotobuf): Include the name of the field
+	  that could not be found in exceptions in getFieldDescriptor
+	  (errors from update / new, etc.).
+
 2013-09-03  Murray Stokely  <murray at FreeBSD.org>
 
 	* inst/NEWS.Rd: Summarize changes since the last release.

Modified: pkg/src/rprotobuf.cpp
===================================================================
--- pkg/src/rprotobuf.cpp	2013-09-04 00:38:59 UTC (rev 527)
+++ pkg/src/rprotobuf.cpp	2013-09-07 06:46:57 UTC (rev 528)
@@ -222,6 +222,7 @@
 GPB::FieldDescriptor* getFieldDescriptor(GPB::Message* message, SEXP name){
 	GPB::FieldDescriptor* field_desc = (GPB::FieldDescriptor*)0;
 	const GPB::Descriptor* desc = message->GetDescriptor() ;
+	std::string error_message = "could not get FieldDescriptor for field";
 	switch( TYPEOF(name) ){
 		case S4SXP:
 		  {
@@ -235,11 +236,13 @@
 		case CHARSXP:
 			{
 				field_desc = (GPB::FieldDescriptor*)desc->FindFieldByName( CHAR(name) ) ;
-				break ;	
+				error_message += string(" '") + CHAR(name) + "'";
+				break ;
 			}
 		case STRSXP:
 			{
 				field_desc = (GPB::FieldDescriptor*)desc->FindFieldByName( CHAR( STRING_ELT(name, 0 ) ) ) ;
+				error_message += string(" '") + CHAR( STRING_ELT(name, 0 )) + "'";
 				break ;
 			}
 		case REALSXP:
@@ -250,7 +253,7 @@
 			}
 	}
 	if( !field_desc ){
-		throwException( "could not get FieldDescriptor for field", "NoSuchFieldException" ) ;
+		throwException( error_message.c_str(), "NoSuchFieldException" ) ;
 	}
 	return field_desc ;
 }



More information about the Rprotobuf-commits mailing list