[tracker/libtracker-sparql: 32/50] Move SparqlError from libtracker-data to libtracker-sparql



commit 8eb03278a651b32124eb1dc05c1fb328ae62392d
Author: Jürg Billeter <j bitron ch>
Date:   Wed Jul 21 15:55:05 2010 +0200

    Move SparqlError from libtracker-data to libtracker-sparql

 src/libtracker-sparql/tracker-connection.vala    |   33 ++++++++++++++--------
 src/libtracker-sparql/tracker-plugin-loader.vala |   30 +++++++++++--------
 2 files changed, 38 insertions(+), 25 deletions(-)
---
diff --git a/src/libtracker-sparql/tracker-connection.vala b/src/libtracker-sparql/tracker-connection.vala
index d875d8a..c47022e 100644
--- a/src/libtracker-sparql/tracker-connection.vala
+++ b/src/libtracker-sparql/tracker-connection.vala
@@ -26,12 +26,21 @@ public const string TRACKER_DBUS_OBJECT_STATISTICS = "/org/freedesktop/Tracker1/
 public const string TRACKER_DBUS_INTERFACE_STEROIDS = TRACKER_DBUS_SERVICE + ".Steroids";
 public const string TRACKER_DBUS_OBJECT_STEROIDS = "/org/freedesktop/Tracker1/Steroids";
 
+public errordomain Tracker.Sparql.Error {
+	PARSE,
+	UNKNOWN_CLASS,
+	UNKNOWN_PROPERTY,
+	TYPE,
+	INTERNAL,
+	UNSUPPORTED
+}
+
 public abstract class Tracker.Sparql.Connection : Object {
 	static bool direct_only;
 	static weak Connection? singleton;
 	static int verbosity = 0;
 
-	public static Connection get () throws GLib.Error {
+	public static Connection get () throws Sparql.Error {
 		if (singleton != null) {
 			assert (!direct_only);
 			return singleton;
@@ -45,7 +54,7 @@ public abstract class Tracker.Sparql.Connection : Object {
 		}
 	}
 
-	public static Connection get_direct () throws GLib.Error {
+	public static Connection get_direct () throws Sparql.Error {
 		if (singleton != null) {
 			assert (direct_only);
 			return singleton;
@@ -123,41 +132,41 @@ public abstract class Tracker.Sparql.Connection : Object {
 	}
 
 	// Query
-	public abstract Cursor? query (string sparql, Cancellable? cancellable = null) throws GLib.Error;
-	public async abstract Cursor? query_async (string sparql, Cancellable? cancellable = null) throws GLib.Error;
+	public abstract Cursor? query (string sparql, Cancellable? cancellable = null) throws Sparql.Error;
+	public async abstract Cursor? query_async (string sparql, Cancellable? cancellable = null) throws Sparql.Error;
 
 	// Update
-	public virtual void update (string sparql, Cancellable? cancellable = null) throws GLib.Error {
+	public virtual void update (string sparql, Cancellable? cancellable = null) throws Sparql.Error {
 		warning ("Interface 'update' not implemented");
 	}
-	public async virtual void update_async (string sparql, int? priority = GLib.Priority.DEFAULT, Cancellable? cancellable = null) throws GLib.Error {
+	public async virtual void update_async (string sparql, int? priority = GLib.Priority.DEFAULT, Cancellable? cancellable = null) throws Sparql.Error {
 		warning ("Interface 'update_async' not implemented");
 	}
 
 	// Only applies to update_async with the right priority. 
 	// Priority is used to identify batch updates.
-	public virtual void update_commit (Cancellable? cancellable = null) throws GLib.Error {
+	public virtual void update_commit (Cancellable? cancellable = null) throws Sparql.Error {
 		warning ("Interface 'update_commit' not implemented");
 	}
-	public async virtual void update_commit_async (Cancellable? cancellable = null) throws GLib.Error {
+	public async virtual void update_commit_async (Cancellable? cancellable = null) throws Sparql.Error {
 		warning ("Interface 'update_commit_async' not implemented");
 	}
 	
 	// Import
-	public virtual void import (File file, Cancellable? cancellable = null) throws GLib.Error {
+	public virtual void import (File file, Cancellable? cancellable = null) throws Sparql.Error {
 		warning ("Interface 'import' not implemented");
 	}
-	public async virtual void import_async (File file, Cancellable? cancellable = null) throws GLib.Error {
+	public async virtual void import_async (File file, Cancellable? cancellable = null) throws Sparql.Error {
 		warning ("Interface 'import_async' not implemented");
 	}
 	
 	// Statistics
-	public virtual Cursor? statistics (Cancellable? cancellable = null) throws GLib.Error {
+	public virtual Cursor? statistics (Cancellable? cancellable = null) throws Sparql.Error {
 		warning ("Interface 'statistics' not implemented");
 		return null;
 	}
 	
-	public async virtual Cursor? statistics_async (Cancellable? cancellable = null) throws GLib.Error {
+	public async virtual Cursor? statistics_async (Cancellable? cancellable = null) throws Sparql.Error {
 		warning ("Interface 'statistics_async' not implemented");
 		return null;
 	}
diff --git a/src/libtracker-sparql/tracker-plugin-loader.vala b/src/libtracker-sparql/tracker-plugin-loader.vala
index ff7228b..6d722e5 100644
--- a/src/libtracker-sparql/tracker-plugin-loader.vala
+++ b/src/libtracker-sparql/tracker-plugin-loader.vala
@@ -24,18 +24,22 @@ class Tracker.Sparql.PluginLoader : Connection {
 
 	private delegate Tracker.Sparql.Connection ModuleInitFunc ();
 
-	public PluginLoader (bool direct_only = false) throws Error
+	public PluginLoader (bool direct_only = false) throws Sparql.Error
 	requires (!initialized) {
 		if (!Module.supported ()) {
 		    return;
 		}
 
-		load_plugins (direct_only);
+		try {
+			load_plugins (direct_only);
+		} catch (GLib.Error e) {
+			throw new Sparql.Error.INTERNAL (e.message);
+		}
 
 		initialized = true;
 	}
 
-	public override Cursor? query (string sparql, Cancellable? cancellable = null) throws GLib.Error {
+	public override Cursor? query (string sparql, Cancellable? cancellable = null) throws Sparql.Error {
 		if (direct != null) {
 			return direct.query (sparql, cancellable);
 		} else {
@@ -43,7 +47,7 @@ class Tracker.Sparql.PluginLoader : Connection {
 		}
 	}
 
-	public async override Cursor? query_async (string sparql, Cancellable? cancellable = null) throws GLib.Error {
+	public async override Cursor? query_async (string sparql, Cancellable? cancellable = null) throws Sparql.Error {
 		if (direct != null) {
 			return yield direct.query_async (sparql, cancellable);
 		} else {
@@ -51,35 +55,35 @@ class Tracker.Sparql.PluginLoader : Connection {
 		}
 	}
 
-	public override void update (string sparql, Cancellable? cancellable = null) throws GLib.Error {
+	public override void update (string sparql, Cancellable? cancellable = null) throws Sparql.Error {
 		bus.update (sparql, cancellable);
 	}
 
-	public async override void update_async (string sparql, int? priority = GLib.Priority.DEFAULT, Cancellable? cancellable = null) throws GLib.Error {
+	public async override void update_async (string sparql, int? priority = GLib.Priority.DEFAULT, Cancellable? cancellable = null) throws Sparql.Error {
 		yield bus.update_async (sparql, priority, cancellable);
 	}
 
-	public override void update_commit (Cancellable? cancellable = null) throws GLib.Error {
+	public override void update_commit (Cancellable? cancellable = null) throws Sparql.Error {
 		bus.update_commit (cancellable);
 	}
 
-	public async override void update_commit_async (Cancellable? cancellable = null) throws GLib.Error {
+	public async override void update_commit_async (Cancellable? cancellable = null) throws Sparql.Error {
 		yield bus.update_commit_async (cancellable);
 	}
 
-	public override void import (File file, Cancellable? cancellable = null) throws GLib.Error {
+	public override void import (File file, Cancellable? cancellable = null) throws Sparql.Error {
 		bus.import (file, cancellable);
 	}
 
-	public async override void import_async (File file, Cancellable? cancellable = null) throws GLib.Error {
+	public async override void import_async (File file, Cancellable? cancellable = null) throws Sparql.Error {
 		yield bus.import_async (file, cancellable);
 	}
 
-	public override Cursor? statistics (Cancellable? cancellable = null) throws GLib.Error {
+	public override Cursor? statistics (Cancellable? cancellable = null) throws Sparql.Error {
 		return bus.statistics (cancellable);
 	}
 
-	public async override Cursor? statistics_async (Cancellable? cancellable = null) throws GLib.Error {
+	public async override Cursor? statistics_async (Cancellable? cancellable = null) throws Sparql.Error {
 		return yield bus.statistics_async (cancellable);
 	}
 
@@ -171,7 +175,7 @@ class Tracker.Sparql.PluginLoader : Connection {
 			debug ("Loaded module source: '%s'", module.name ());
 
 			return c;
-		} catch (Error e) {
+		} catch (GLib.Error e) {
 			if (required) {
 				// plugin required => error is fatal
 				throw e;



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