[tracker/wip/carlosg/grilo-fixes: 4/5] libtracker-data: Propagate remote error messages through the service vtab



commit ff5bd020113f237e001be1e4a0564c805421f1dd
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sun May 24 12:31:12 2020 +0200

    libtracker-data: Propagate remote error messages through the service vtab
    
    This makes remote errors propagate through as sqlite errors, and eventually
    as GErrors again. Much better than warning and propagating through a
    "SQLITE logic error" message.

 src/libtracker-data/tracker-vtab-service.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
---
diff --git a/src/libtracker-data/tracker-vtab-service.c b/src/libtracker-data/tracker-vtab-service.c
index b3b1861ed..8e0a0b992 100644
--- a/src/libtracker-data/tracker-vtab-service.c
+++ b/src/libtracker-data/tracker-vtab-service.c
@@ -61,6 +61,18 @@ typedef struct {
        int op;
 } ConstraintData;
 
+static void
+tracker_service_cursor_set_vtab_error (TrackerServiceCursor *cursor,
+                                       const gchar          *message)
+{
+       TrackerServiceVTab *vtab = cursor->vtab;
+
+       if (vtab->parent.zErrMsg)
+               sqlite3_free (vtab->parent.zErrMsg);
+       vtab->parent.zErrMsg = sqlite3_mprintf ("In service '%s': %s",
+                                               cursor->service, message);
+}
+
 static void
 tracker_service_module_free (gpointer data)
 {
@@ -399,7 +411,7 @@ fail:
                g_error_free (error);
                return SQLITE_OK;
        } else {
-               g_warning ("Could not create remote cursor: %s\n", error->message);
+               tracker_service_cursor_set_vtab_error (cursor, error->message);
                g_error_free (error);
                return SQLITE_ERROR;
        }


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