[epiphany/gnome-3-34] bookmarks-import: Fix error handling
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany/gnome-3-34] bookmarks-import: Fix error handling
- Date: Thu, 17 Oct 2019 07:24:03 +0000 (UTC)
commit 6edcef7ce5407c7d862e14942655faa978032058
Author: Michael Catanzaro <mcatanzaro gnome org>
Date: Sun Oct 6 19:41:19 2019 +0000
bookmarks-import: Fix error handling
We need to, at minimum, use g_clear_error() to ensure it is NULL before
passing it to g_set_error(). But it's simpler to use a separate GError
for internal errors instead.
Now instead of crashing, we'll show a nice error message "Firefox
bookmarks could not be retrieved!" This isn't ideal, however, because
clearly the code expects to trigger the earlier error message ("Close
Firefox and try again") but is failing to do so.
Fixes #965
(cherry picked from commit 6112a18badab76ec854cb3e0b84be02a8e173980)
src/bookmarks/ephy-bookmarks-import.c | 23 ++++++++++++-----------
1 file changed, 12 insertions(+), 11 deletions(-)
---
diff --git a/src/bookmarks/ephy-bookmarks-import.c b/src/bookmarks/ephy-bookmarks-import.c
index 8862b995f..055bbe327 100644
--- a/src/bookmarks/ephy-bookmarks-import.c
+++ b/src/bookmarks/ephy-bookmarks-import.c
@@ -219,6 +219,7 @@ ephy_bookmarks_import_from_firefox (EphyBookmarksManager *manager,
GSequence *bookmarks = NULL;
gboolean ret = TRUE;
gchar *filename;
+ GError *my_error = NULL;
const char *statement_str = "SELECT b.id, p.url, b.title, b.dateAdded, b.guid, g.title "
"FROM moz_bookmarks b "
"JOIN moz_places p ON b.fk=p.id "
@@ -235,10 +236,10 @@ ephy_bookmarks_import_from_firefox (EphyBookmarksManager *manager,
NULL);
connection = ephy_sqlite_connection_new (EPHY_SQLITE_CONNECTION_MODE_READ_ONLY, filename);
- ephy_sqlite_connection_open (connection, error);
- if (*error) {
- g_warning ("Could not open database at %s: %s", filename, (*error)->message);
- g_error_free (*error);
+ ephy_sqlite_connection_open (connection, &my_error);
+ if (my_error) {
+ g_warning ("Could not open database at %s: %s", filename, my_error->message);
+ g_error_free (my_error);
g_set_error (error,
BOOKMARKS_IMPORT_ERROR,
BOOKMARKS_IMPORT_ERROR_BOOKMARKS,
@@ -248,10 +249,10 @@ ephy_bookmarks_import_from_firefox (EphyBookmarksManager *manager,
statement = ephy_sqlite_connection_create_statement (connection,
statement_str,
- error);
+ &my_error);
if (statement == NULL) {
- g_warning ("Could not build bookmarks query statement: %s", (*error)->message);
- g_error_free (*error);
+ g_warning ("Could not build bookmarks query statement: %s", my_error->message);
+ g_error_free (my_error);
g_set_error (error,
BOOKMARKS_IMPORT_ERROR,
BOOKMARKS_IMPORT_ERROR_BOOKMARKS,
@@ -261,7 +262,7 @@ ephy_bookmarks_import_from_firefox (EphyBookmarksManager *manager,
}
bookmarks = g_sequence_new (g_object_unref);
- while (ephy_sqlite_statement_step (statement, error)) {
+ while (ephy_sqlite_statement_step (statement, &my_error)) {
int bookmark_id = ephy_sqlite_statement_get_column_as_int (statement, 0);
const char *url = ephy_sqlite_statement_get_column_as_string (statement, 1);
const char *title = ephy_sqlite_statement_get_column_as_string (statement, 2);
@@ -281,9 +282,9 @@ ephy_bookmarks_import_from_firefox (EphyBookmarksManager *manager,
g_sequence_prepend (bookmarks, bookmark);
}
- if (*error) {
- g_warning ("Could not execute bookmarks query statement: %s", (*error)->message);
- g_error_free (*error);
+ if (my_error) {
+ g_warning ("Could not execute bookmarks query statement: %s", my_error->message);
+ g_error_free (my_error);
g_set_error (error,
BOOKMARKS_IMPORT_ERROR,
BOOKMARKS_IMPORT_ERROR_BOOKMARKS,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]