[tracker/parser] Handling passing a non-existing variable in a sparql query



commit 9d67d065692af7fcca38f6ebdbe9a9b3609b5781
Author: Philip Van Hoof <philip codeminded be>
Date:   Tue Aug 11 17:59:54 2009 +0200

    Handling passing a non-existing variable in a sparql query

 src/libtracker-data/tracker-sparql-query.vala |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
---
diff --git a/src/libtracker-data/tracker-sparql-query.vala b/src/libtracker-data/tracker-sparql-query.vala
index 587fb7c..b9d73fa 100644
--- a/src/libtracker-data/tracker-sparql-query.vala
+++ b/src/libtracker-data/tracker-sparql-query.vala
@@ -433,9 +433,13 @@ public class Tracker.SparqlQuery : Object {
 		}
 	}
 
-	string get_sql_for_variable (string variable_name) {
+	string get_sql_for_variable (string variable_name) throws SparqlError {
 		var binding = var_map.lookup (variable_name);
-		assert (binding != null);
+
+		if (binding == null) {
+			throw new SparqlError.PARSE ("`%s' is not a valid variable".printf (variable_name));
+		}
+
 		if (binding.is_uri) {
 			return "(SELECT Uri FROM \"rdfs:Resource\" WHERE ID = \"%s_u\")".printf (variable_name);
 		} else if (binding.is_boolean) {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]