[rygel] media-db: Throw error on creation failure



commit 143c00e0a7d2cbd4bafe6ce3d3b0962de667ad14
Author: Jens Georg <mail jensge org>
Date:   Sun Jan 31 15:14:12 2010 +0100

    media-db: Throw error on creation failure

 src/rygel/rygel-database.vala |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)
---
diff --git a/src/rygel/rygel-database.vala b/src/rygel/rygel-database.vala
index a5140a3..8185d89 100644
--- a/src/rygel/rygel-database.vala
+++ b/src/rygel/rygel-database.vala
@@ -23,6 +23,7 @@
 using Sqlite;
 
 public errordomain Rygel.DatabaseError {
+    IO_ERROR,
     SQLITE_ERROR
 }
 
@@ -31,7 +32,7 @@ internal class Rygel.Database : Object {
 
     public delegate bool RowCallback (Sqlite.Statement stmt);
 
-    public Database (string name) {
+    public Database (string name) throws DatabaseError {
         var dirname = Path.build_filename (Environment.get_user_cache_dir (),
                                            "rygel");
         DirUtils.create_with_parents (dirname, 0750);
@@ -39,12 +40,13 @@ internal class Rygel.Database : Object {
         debug ("Using database file %s", db_file);
         var rc = Sqlite.Database.open (db_file, out this.db);
         if (rc != Sqlite.OK) {
-            warning ("Failed to open database: %d, %s",
-                     rc,
-                     db.errmsg ());
+            var msg = "Failed to open database: %d, %s".printf (
+                       rc,
+                       db.errmsg ());
 
-            return;
+            throw new DatabaseError.IO_ERROR (msg);
         }
+
         this.db.exec ("PRAGMA cache_size = 32768");
         this.db.exec ("PRAGMA synchronous = OFF");
         this.db.exec ("PRAGMA temp_store = MEMORY");



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