[tracker/direct-access: 95/121] libtracker-direct: Handle initialization failure



commit 62d8420556892fa98a9cdfdc1bcb7512f326a734
Author: Jürg Billeter <j bitron ch>
Date:   Wed Jul 21 16:59:12 2010 +0200

    libtracker-direct: Handle initialization failure

 src/libtracker-direct/tracker-direct.vala |   16 +++++++++++-----
 1 files changed, 11 insertions(+), 5 deletions(-)
---
diff --git a/src/libtracker-direct/tracker-direct.vala b/src/libtracker-direct/tracker-direct.vala
index 32953ae..d1cd63e 100644
--- a/src/libtracker-direct/tracker-direct.vala
+++ b/src/libtracker-direct/tracker-direct.vala
@@ -21,10 +21,12 @@ public class Tracker.Direct.Connection : Tracker.Sparql.Connection {
 	// only single connection is currently supported per process
 	static bool initialized;
 
-	public Connection ()
+	public Connection () throws Sparql.Error
 	requires (!initialized) {
 		initialized = true;
-		Data.Manager.init (DBManagerFlags.READONLY, null, null, false, null, null);
+		if (!Data.Manager.init (DBManagerFlags.READONLY, null, null, false, null, null)) {
+			throw new Sparql.Error.INTERNAL ("Unable to initialize database");
+		}
 	}
 
 	~Connection () {
@@ -52,7 +54,11 @@ public class Tracker.Direct.Connection : Tracker.Sparql.Connection {
 	}
 }
 
-public Tracker.Sparql.Connection module_init () {
-	Tracker.Sparql.Connection plugin = new Tracker.Direct.Connection ();
-	return plugin;
+public Tracker.Sparql.Connection? module_init () {
+	try {
+		Tracker.Sparql.Connection plugin = new Tracker.Direct.Connection ();
+		return plugin;
+	} catch (Tracker.Sparql.Error e) {
+		return null;
+	}
 }



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