[tracker/error-handling: 5/6] libtracker-data, tracker-store: Handle out-of-space errors by wrapping them



commit 83d67df8eac5f864b113ea40140d5d3d50b62dbb
Author: Philip Van Hoof <philip codeminded be>
Date:   Tue Feb 8 17:46:30 2011 +0100

    libtracker-data, tracker-store: Handle out-of-space errors by wrapping them
    
    Our D-Bus APIs want known errors to be passed over D-Bus, not unknown
    internal errors. So we wrap the error.

 src/libtracker-data/libtracker-data.vapi          |    3 ++-
 src/libtracker-data/tracker-db-interface-sqlite.c |    2 +-
 src/libtracker-data/tracker-db-interface.h        |    3 ++-
 src/tracker-store/tracker-resources.vala          |    8 ++++++++
 src/tracker-store/tracker-steroids.vala           |    2 ++
 5 files changed, 15 insertions(+), 3 deletions(-)
---
diff --git a/src/libtracker-data/libtracker-data.vapi b/src/libtracker-data/libtracker-data.vapi
index 9f431a3..4b29ed2 100644
--- a/src/libtracker-data/libtracker-data.vapi
+++ b/src/libtracker-data/libtracker-data.vapi
@@ -32,7 +32,8 @@ namespace Tracker {
 		QUERY_ERROR,
 		CORRUPT,
 		INTERRUPTED,
-		OPEN_ERROR
+		OPEN_ERROR,
+		NO_SPACE
 	}
 
 	[CCode (cprefix = "TRACKER_DB_STATEMENT_CACHE_TYPE_", cheader_filename = "libtracker-data/tracker-db-interface.h")]
diff --git a/src/libtracker-data/tracker-db-interface-sqlite.c b/src/libtracker-data/tracker-db-interface-sqlite.c
index 8be803a..e5d4915 100644
--- a/src/libtracker-data/tracker-db-interface-sqlite.c
+++ b/src/libtracker-data/tracker-db-interface-sqlite.c
@@ -1145,7 +1145,7 @@ execute_stmt (TrackerDBInterface  *interface,
 			} else {
 				g_set_error (error,
 				             TRACKER_DB_INTERFACE_ERROR,
-				             TRACKER_DB_QUERY_ERROR,
+				             errno != ENOSPC ? TRACKER_DB_QUERY_ERROR : TRACKER_DB_NO_SPACE,
 				             "%s%s%s%s",
 				             sqlite3_errmsg (interface->db),
 				             errno != 0 ? " (" : "",
diff --git a/src/libtracker-data/tracker-db-interface.h b/src/libtracker-data/tracker-db-interface.h
index 1dcdf95..0352a4d 100644
--- a/src/libtracker-data/tracker-db-interface.h
+++ b/src/libtracker-data/tracker-db-interface.h
@@ -64,7 +64,8 @@ typedef enum {
 	TRACKER_DB_QUERY_ERROR,
 	TRACKER_DB_CORRUPT,
 	TRACKER_DB_INTERRUPTED,
-	TRACKER_DB_OPEN_ERROR
+	TRACKER_DB_OPEN_ERROR,
+	TRACKER_DB_NO_SPACE
 } TrackerDBInterfaceError;
 
 typedef enum {
diff --git a/src/tracker-store/tracker-resources.vala b/src/tracker-store/tracker-resources.vala
index e482b1e..a94d3fd 100644
--- a/src/tracker-store/tracker-resources.vala
+++ b/src/tracker-store/tracker-resources.vala
@@ -68,6 +68,8 @@ public class Tracker.Resources : Object {
 			yield Tracker.Store.queue_turtle_import (file, sender);
 
 			request.end ();
+		} catch (DBInterfaceError.NO_SPACE ie) {
+			throw new Sparql.Error.NO_SPACE (ie.message);
 		} catch (Error e) {
 			request.end (e);
 			throw e;
@@ -120,6 +122,8 @@ public class Tracker.Resources : Object {
 			yield Tracker.Store.sparql_update (update, Tracker.Store.Priority.HIGH, sender);
 
 			request.end ();
+		} catch (DBInterfaceError.NO_SPACE ie) {
+			throw new Sparql.Error.NO_SPACE (ie.message);
 		} catch (Error e) {
 			request.end (e);
 			throw e;
@@ -148,6 +152,8 @@ public class Tracker.Resources : Object {
 			}
 
 			return builder.end ();
+		} catch (DBInterfaceError.NO_SPACE ie) {
+			throw new Sparql.Error.NO_SPACE (ie.message);
 		} catch (Error e) {
 			request.end (e);
 			throw e;
@@ -169,6 +175,8 @@ public class Tracker.Resources : Object {
 			yield Tracker.Store.sparql_update (update, Tracker.Store.Priority.LOW, sender);
 
 			request.end ();
+		} catch (DBInterfaceError.NO_SPACE ie) {
+			throw new Sparql.Error.NO_SPACE (ie.message);
 		} catch (Error e) {
 			request.end (e);
 			throw e;
diff --git a/src/tracker-store/tracker-steroids.vala b/src/tracker-store/tracker-steroids.vala
index 0a9b109..b15dd9d 100644
--- a/src/tracker-store/tracker-steroids.vala
+++ b/src/tracker-store/tracker-steroids.vala
@@ -134,6 +134,8 @@ public class Tracker.Steroids : Object {
 
 				return builder.end ();
 			}
+		} catch (DBInterfaceError.NO_SPACE ie) {
+			throw new Sparql.Error.NO_SPACE (ie.message);
 		} catch (Error e) {
 			request.end (e);
 			throw e;



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