From: scottmk Date: Wed, 25 Feb 2009 13:36:27 +0000 (+0000) Subject: Enhance error handling in SELECT(). In two cases, X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=bda149c4f5103cf22d55572126786b466356bdd5;p=evergreen%2Ftadl.git 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 git-svn-id: svn://svn.open-ils.org/ILS/trunk@12296 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/src/c-apps/oils_cstore.c b/Open-ILS/src/c-apps/oils_cstore.c index 2a6824b855..e6bf082b22 100644 --- a/Open-ILS/src/c-apps/oils_cstore.c +++ b/Open-ILS/src/c-apps/oils_cstore.c @@ -2423,8 +2423,22 @@ char* SELECT ( 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 @@ char* SELECT ( 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) );