[tracker/error-handling: 5/6] libtracker-data, tracker-store: Handle out-of-space errors by wrapping them
- From: Philip Van Hoof <pvanhoof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/error-handling: 5/6] libtracker-data, tracker-store: Handle out-of-space errors by wrapping them
- Date: Wed, 9 Feb 2011 11:08:49 +0000 (UTC)
commit 7b0483a9669702fcd9d7adc3cc57c9c4092ea7ab
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..c85438b 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,
+ OUT_OF_SPACE_ERROR
}
[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..97939f4 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_OUT_OF_SPACE_ERROR,
"%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..5b66a2c 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_OUT_OF_SPACE_ERROR
} TrackerDBInterfaceError;
typedef enum {
diff --git a/src/tracker-store/tracker-resources.vala b/src/tracker-store/tracker-resources.vala
index e482b1e..028fd28 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.OUT_OF_SPACE_ERROR 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.OUT_OF_SPACE_ERROR 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.OUT_OF_SPACE_ERROR 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.OUT_OF_SPACE_ERROR 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..56f0779 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.OUT_OF_SPACE_ERROR 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]