[open-ils-commits] r12296 - trunk/Open-ILS/src/c-apps (scottmk)

svn at svn.open-ils.org svn at svn.open-ils.org
Wed Feb 25 08:36:28 EST 2009


Author: scottmk
Date: 2009-02-25 08:36:27 -0500 (Wed, 25 Feb 2009)
New Revision: 12296

Modified:
   trunk/Open-ILS/src/c-apps/oils_cstore.c
Log:
Enhance error handling in SELECT().  In two cases,
issue a helpful message before bailing out:

1. When the FROM clause is missing or empty

2. When the FROM clause is a JSON_HASH with more
than one entry


Modified: trunk/Open-ILS/src/c-apps/oils_cstore.c
===================================================================
--- trunk/Open-ILS/src/c-apps/oils_cstore.c	2009-02-25 05:33:31 UTC (rev 12295)
+++ trunk/Open-ILS/src/c-apps/oils_cstore.c	2009-02-25 13:36:27 UTC (rev 12296)
@@ -2423,8 +2423,22 @@
 	osrfHash* core_meta = NULL;
 
 	// punt if there's no core class
-	if (!join_hash || ( join_hash->type == JSON_HASH && !join_hash->size ))
+	if (!join_hash || ( join_hash->type == JSON_HASH && !join_hash->size )) {
+		osrfLogError(
+			OSRF_LOG_MARK,
+			"%s: FROM clause is missing or empty",
+			MODULENAME
+		);
+		if( ctx )
+			osrfAppSessionStatus(
+				ctx->session,
+				OSRF_STATUS_INTERNALSERVERERROR,
+				"osrfMethodException",
+				ctx->request,
+				"FROM clause is missing or empty in JSON query"
+			);
 		return NULL;
+	}
 
 	// get the core class -- the only key of the top level FROM clause, or a string
 	if (join_hash->type == JSON_HASH) {
@@ -2438,11 +2452,25 @@
 
 		jsonIteratorFree( tmp_itr );
 		snode = NULL;
-		
+
 		// There shouldn't be more than one entry in join_hash
-		if( extra )
+		if( extra ) {
+			osrfLogError(
+				OSRF_LOG_MARK,
+				"%s: Malformed FROM clause: extra entry in JSON_HASH",
+				MODULENAME
+			);
+			if( ctx )
+				osrfAppSessionStatus(
+					ctx->session,
+					OSRF_STATUS_INTERNALSERVERERROR,
+					"osrfMethodException",
+					ctx->request,
+					"Malformed FROM clause in JSON query"
+				);
+			free( core_class );
 			return NULL;	// Malformed join_hash; extra entry
-
+		}
 	} else if (join_hash->type == JSON_ARRAY) {
 		from_function = 1;
 		core_class = jsonObjectToSimpleString( jsonObjectGetIndex(join_hash, 0) );



More information about the open-ils-commits mailing list