[tracker/rss-enclosures] libtracker-sparql: Fix error handling



commit 490978e2aa45a74cc82e647e7af1ce22557ed6c6
Author: Jürg Billeter <j bitron ch>
Date:   Mon Oct 25 13:35:07 2010 +0200

    libtracker-sparql: Fix error handling

 src/libtracker-sparql/tracker-backend.vala    |   46 ++++++++++---------------
 src/libtracker-sparql/tracker-connection.vala |   16 ++++----
 2 files changed, 26 insertions(+), 36 deletions(-)
---
diff --git a/src/libtracker-sparql/tracker-backend.vala b/src/libtracker-sparql/tracker-backend.vala
index ba48166..d4b7df7 100644
--- a/src/libtracker-sparql/tracker-backend.vala
+++ b/src/libtracker-sparql/tracker-backend.vala
@@ -57,42 +57,32 @@ class Tracker.Sparql.Backend : Connection {
 		is_constructed = true;
 	}
 
-	public override void init () throws Sparql.Error
+	public override void init () throws Sparql.Error, IOError, DBusError
 	requires (is_constructed) {
-		try {
-			Tracker.Backend.Status status = Bus.get_proxy_sync (BusType.SESSION,
-			                                                    TRACKER_DBUS_SERVICE,
-			                                                    TRACKER_DBUS_OBJECT_STATUS);
-			status.set_default_timeout (int.MAX);
-
-			// Makes sure the sevice is available
-			debug ("Waiting for service to become available synchronously...");
-			status.wait ();
-			debug ("Service is ready");
-		} catch (DBusError e) {
-			warning ("Could not connect to D-Bus service:'%s': %s", TRACKER_DBUS_INTERFACE_RESOURCES, e.message);
-			throw new Sparql.Error.INTERNAL (e.message);
-		}
+		Tracker.Backend.Status status = Bus.get_proxy_sync (BusType.SESSION,
+		                                                    TRACKER_DBUS_SERVICE,
+		                                                    TRACKER_DBUS_OBJECT_STATUS);
+		status.set_default_timeout (int.MAX);
+
+		// Makes sure the sevice is available
+		debug ("Waiting for service to become available synchronously...");
+		status.wait ();
+		debug ("Service is ready");
 
 		is_initialized = true;
 	}
 
-	public async override void init_async () throws Sparql.Error
+	public async override void init_async () throws Sparql.Error, IOError, DBusError
 	requires (is_constructed) {
-		try {
-			Tracker.Backend.Status status = Bus.get_proxy_sync (BusType.SESSION,
-			                                                    TRACKER_DBUS_SERVICE,
-			                                                    TRACKER_DBUS_OBJECT_STATUS);
-			status.set_default_timeout (int.MAX);
-
-			// Makes sure the sevice is available
-			debug ("Waiting for service to become available asynchronously...");
-			yield status.wait_async ();
-			debug ("Service is ready");
-		} catch (DBusError e) {
-			warning ("Could not connect to D-Bus service:'%s': %s", TRACKER_DBUS_INTERFACE_RESOURCES, e.message);
-			throw new Sparql.Error.INTERNAL (e.message);
-		}
+		Tracker.Backend.Status status = Bus.get_proxy_sync (BusType.SESSION,
+		                                                    TRACKER_DBUS_SERVICE,
+		                                                    TRACKER_DBUS_OBJECT_STATUS);
+		status.set_default_timeout (int.MAX);
+
+		// Makes sure the sevice is available
+		debug ("Waiting for service to become available asynchronously...");
+		yield status.wait_async ();
+		debug ("Service is ready");
 
 		is_initialized = true;
 	}
diff --git a/src/libtracker-sparql/tracker-connection.vala b/src/libtracker-sparql/tracker-connection.vala
index a48ef60..72f6bfd 100644
--- a/src/libtracker-sparql/tracker-connection.vala
+++ b/src/libtracker-sparql/tracker-connection.vala
@@ -85,7 +85,7 @@ public abstract class Tracker.Sparql.Connection : Object {
 	static bool log_initialized;
 	static StaticMutex door;
 
-	private static new Connection get_internal (bool is_direct_only = false, Cancellable? cancellable = null) throws Sparql.Error, IOError {
+	private static new Connection get_internal (bool is_direct_only = false, Cancellable? cancellable = null) throws Sparql.Error, IOError, DBusError {
 		door.lock ();
 
 		if (singleton != null) {
@@ -114,7 +114,7 @@ public abstract class Tracker.Sparql.Connection : Object {
 		return singleton;
 	}
 
-	private async static new Connection get_internal_async (bool is_direct_only = false, Cancellable? cancellable = null) throws Sparql.Error, IOError {
+	private async static new Connection get_internal_async (bool is_direct_only = false, Cancellable? cancellable = null) throws Sparql.Error, IOError, DBusError {
 		door.lock ();
 
 		if (singleton != null) {
@@ -173,7 +173,7 @@ public abstract class Tracker.Sparql.Connection : Object {
 	 *
 	 * Since: 0.10
 	 */
-	public async static new Connection get_async (Cancellable? cancellable = null) throws Sparql.Error, IOError {
+	public async static new Connection get_async (Cancellable? cancellable = null) throws Sparql.Error, IOError, DBusError {
 		return yield get_internal_async (false, cancellable);
 	}
 
@@ -216,7 +216,7 @@ public abstract class Tracker.Sparql.Connection : Object {
 	 *
 	 * Since: 0.10
 	 */
-	public static new Connection get (Cancellable? cancellable = null) throws Sparql.Error, IOError {
+	public static new Connection get (Cancellable? cancellable = null) throws Sparql.Error, IOError, DBusError {
 		return get_internal (false, cancellable);
 	}
 
@@ -251,7 +251,7 @@ public abstract class Tracker.Sparql.Connection : Object {
 	 *
 	 * Since: 0.10
 	 */
-	public async static Connection get_direct_async (Cancellable? cancellable = null) throws Sparql.Error, IOError {
+	public async static Connection get_direct_async (Cancellable? cancellable = null) throws Sparql.Error, IOError, DBusError {
 		return yield get_internal_async (true, cancellable);
 	}
 
@@ -271,7 +271,7 @@ public abstract class Tracker.Sparql.Connection : Object {
 	 *
 	 * Since 0.10
 	 */
-	public static new Connection get_direct (Cancellable? cancellable = null) throws Sparql.Error, IOError {
+	public static new Connection get_direct (Cancellable? cancellable = null) throws Sparql.Error, IOError, DBusError {
 		return get_internal (true, cancellable);
 	}
 
@@ -324,11 +324,11 @@ public abstract class Tracker.Sparql.Connection : Object {
 		/* do nothing */
 	}
 
-	public virtual void init () throws Sparql.Error {
+	public virtual void init () throws Sparql.Error, IOError, DBusError {
 		warning ("Interface 'init' not implemented");
 	}
 
-	public async virtual void init_async () throws Sparql.Error {
+	public async virtual void init_async () throws Sparql.Error, IOError, DBusError {
 		warning ("Interface 'init_async' not implemented");
 	}
 



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