summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorGaël Bonithon <gael@xfce.org>2021-12-26 00:06:34 +0100
committerGaël Bonithon <gael@xfce.org>2021-12-26 18:30:04 +0100
commit49ffba98d7cf9626a1470bc49a53596300fe3550 (patch)
tree617a9acf683f60bcda0faa8446cacbefc8d423dc /plugins
parentef518751bd744a48a165dc7c285f98b960c64a75 (diff)
downloadtumbler-49ffba98d7cf9626a1470bc49a53596300fe3550.tar.gz
Error handling: Fit to the spec and complete message if needed
A parameter is added to Tumbler's internal error signals to account for the error domain, and the error code `TUMBLER_ERROR_OTHER_ERROR_DOMAIN` is added to indicate that the error originated from a third-party API. When sending the error signal via D-Bus, cancelling errors are filtered out, and when the error originates from a third-party API, the error message is prefixed with the domain and code of that error, in a possibly parsable format. Fixes #49.
Diffstat (limited to 'plugins')
-rw-r--r--plugins/cover-thumbnailer/cover-thumbnailer.c2
-rw-r--r--plugins/desktop-thumbnailer/desktop-thumbnailer.c3
-rw-r--r--plugins/ffmpeg-thumbnailer/ffmpeg-thumbnailer.c18
-rw-r--r--plugins/font-thumbnailer/font-thumbnailer.c17
-rw-r--r--plugins/gepub-thumbnailer/gepub-thumbnailer.c8
-rw-r--r--plugins/gst-thumbnailer/gst-thumbnailer.c9
-rw-r--r--plugins/jpeg-thumbnailer/jpeg-thumbnailer.c3
-rw-r--r--plugins/odf-thumbnailer/odf-thumbnailer.c6
-rw-r--r--plugins/pixbuf-thumbnailer/pixbuf-thumbnailer.c11
-rw-r--r--plugins/poppler-thumbnailer/poppler-thumbnailer.c15
-rw-r--r--plugins/raw-thumbnailer/raw-thumbnailer.c3
11 files changed, 60 insertions, 35 deletions
diff --git a/plugins/cover-thumbnailer/cover-thumbnailer.c b/plugins/cover-thumbnailer/cover-thumbnailer.c
index 4758dee..e1448b0 100644
--- a/plugins/cover-thumbnailer/cover-thumbnailer.c
+++ b/plugins/cover-thumbnailer/cover-thumbnailer.c
@@ -673,7 +673,7 @@ cover_thumbnailer_create (TumblerAbstractThumbnailer *thumbnailer,
if (error != NULL)
{
g_signal_emit_by_name (thumbnailer, "error", uri,
- error->code, error->message);
+ error->domain, error->code, error->message);
g_error_free (error);
}
else
diff --git a/plugins/desktop-thumbnailer/desktop-thumbnailer.c b/plugins/desktop-thumbnailer/desktop-thumbnailer.c
index 7304ea6..96e357e 100644
--- a/plugins/desktop-thumbnailer/desktop-thumbnailer.c
+++ b/plugins/desktop-thumbnailer/desktop-thumbnailer.c
@@ -393,7 +393,8 @@ desktop_thumbnailer_create (TumblerAbstractThumbnailer *thumbnailer,
if (error != NULL)
{
- g_signal_emit_by_name (thumbnailer, "error", uri, error->code, error->message);
+ g_signal_emit_by_name (thumbnailer, "error", uri,
+ error->domain, error->code, error->message);
g_error_free (error);
}
else
diff --git a/plugins/ffmpeg-thumbnailer/ffmpeg-thumbnailer.c b/plugins/ffmpeg-thumbnailer/ffmpeg-thumbnailer.c
index f2edf1e..3b3494e 100644
--- a/plugins/ffmpeg-thumbnailer/ffmpeg-thumbnailer.c
+++ b/plugins/ffmpeg-thumbnailer/ffmpeg-thumbnailer.c
@@ -163,7 +163,8 @@ ffmpeg_thumbnailer_create (TumblerAbstractThumbnailer *thumbnailer,
/* there was an error, emit error signal */
g_set_error (&error, TUMBLER_ERROR, TUMBLER_ERROR_NO_CONTENT,
TUMBLER_ERROR_MESSAGE_CREATION_FAILED);
- g_signal_emit_by_name (thumbnailer, "error", uri, error->code, error->message);
+ g_signal_emit_by_name (thumbnailer, "error", uri,
+ error->domain, error->code, error->message);
g_error_free (error);
return;
@@ -194,7 +195,8 @@ ffmpeg_thumbnailer_create (TumblerAbstractThumbnailer *thumbnailer,
/* there was an error, emit error signal */
g_set_error (&error, TUMBLER_ERROR, TUMBLER_ERROR_INVALID_FORMAT,
TUMBLER_ERROR_MESSAGE_CREATION_FAILED);
- g_signal_emit_by_name (thumbnailer, "error", uri, error->code, error->message);
+ g_signal_emit_by_name (thumbnailer, "error", uri,
+ error->domain, error->code, error->message);
g_error_free (error);
/* clean up */
@@ -209,7 +211,8 @@ ffmpeg_thumbnailer_create (TumblerAbstractThumbnailer *thumbnailer,
/* there was an error, emit error signal */
g_set_error (&error, TUMBLER_ERROR, TUMBLER_ERROR_INVALID_FORMAT,
TUMBLER_ERROR_MESSAGE_CREATION_FAILED);
- g_signal_emit_by_name (thumbnailer, "error", uri, error->code, error->message);
+ g_signal_emit_by_name (thumbnailer, "error", uri,
+ error->domain, error->code, error->message);
g_error_free (error);
/* clean up */
@@ -228,7 +231,8 @@ ffmpeg_thumbnailer_create (TumblerAbstractThumbnailer *thumbnailer,
/* there was an error, emit error signal */
g_set_error (&error, TUMBLER_ERROR, TUMBLER_ERROR_INVALID_FORMAT,
TUMBLER_ERROR_MESSAGE_CREATION_FAILED);
- g_signal_emit_by_name (thumbnailer, "error", uri, error->code, error->message);
+ g_signal_emit_by_name (thumbnailer, "error", uri,
+ error->domain, error->code, error->message);
g_error_free (error);
/* clean up */
@@ -245,7 +249,8 @@ ffmpeg_thumbnailer_create (TumblerAbstractThumbnailer *thumbnailer,
if (v_pixbuf == NULL)
{
/* emit an error signal */
- g_signal_emit_by_name (thumbnailer, "error", uri, error->code, error->message);
+ g_signal_emit_by_name (thumbnailer, "error", uri,
+ error->domain, error->code, error->message);
g_error_free (error);
/* clean up */
@@ -277,7 +282,8 @@ ffmpeg_thumbnailer_create (TumblerAbstractThumbnailer *thumbnailer,
if (error != NULL)
{
/* emit an error signal */
- g_signal_emit_by_name (thumbnailer, "error", uri, error->code, error->message);
+ g_signal_emit_by_name (thumbnailer, "error", uri,
+ error->domain, error->code, error->message);
g_error_free (error);
}
else
diff --git a/plugins/font-thumbnailer/font-thumbnailer.c b/plugins/font-thumbnailer/font-thumbnailer.c
index f9ed136..a816cdf 100644
--- a/plugins/font-thumbnailer/font-thumbnailer.c
+++ b/plugins/font-thumbnailer/font-thumbnailer.c
@@ -429,7 +429,8 @@ font_thumbnailer_create (TumblerAbstractThumbnailer *thumbnailer,
/* there was an error in the freetype initialization, abort */
error_msg = g_strdup_printf (_("Could not initialize freetype: %s"),
ft_strerror (font_thumbnailer->library_error));
- g_signal_emit_by_name (thumbnailer, "error", uri, TUMBLER_ERROR_UNSUPPORTED, error_msg);
+ g_signal_emit_by_name (thumbnailer, "error", uri,
+ TUMBLER_ERROR, TUMBLER_ERROR_UNSUPPORTED, error_msg);
g_free (error_msg);
return;
}
@@ -441,7 +442,8 @@ font_thumbnailer_create (TumblerAbstractThumbnailer *thumbnailer,
/* there was an error, emit error signal */
error_msg = g_strdup_printf (_("Could not load file contents: %s"),
error->message);
- g_signal_emit_by_name (thumbnailer, "error", uri, error->code, error_msg);
+ g_signal_emit_by_name (thumbnailer, "error", uri,
+ error->domain, error->code, error_msg);
g_free (error_msg);
/* clean up */
@@ -460,7 +462,8 @@ font_thumbnailer_create (TumblerAbstractThumbnailer *thumbnailer,
/* the font file could not be loaded, emit an error signal */
error_msg = g_strdup_printf (_("Could not open font file: %s"),
ft_strerror (ft_error));
- g_signal_emit_by_name (thumbnailer, "error", uri, TUMBLER_ERROR_NO_CONTENT, error_msg);
+ g_signal_emit_by_name (thumbnailer, "error", uri,
+ TUMBLER_ERROR, TUMBLER_ERROR_NO_CONTENT, error_msg);
g_free (error_msg);
/* clean up */
@@ -485,7 +488,7 @@ font_thumbnailer_create (TumblerAbstractThumbnailer *thumbnailer,
error_msg = g_strdup_printf (_("Could not set the character map: %s"),
ft_strerror (ft_error));
g_signal_emit_by_name (thumbnailer, "error", uri,
- TUMBLER_ERROR_INVALID_FORMAT, error_msg);
+ TUMBLER_ERROR, TUMBLER_ERROR_INVALID_FORMAT, error_msg);
g_free (error_msg);
/* clean up */
@@ -512,7 +515,8 @@ font_thumbnailer_create (TumblerAbstractThumbnailer *thumbnailer,
/* emit an error signal */
error_msg = g_strdup_printf (_("Could not render glyphs: %s"),
ft_strerror (ft_error));
- g_signal_emit_by_name (thumbnailer, "error", uri, TUMBLER_ERROR_INVALID_FORMAT, error_msg);
+ g_signal_emit_by_name (thumbnailer, "error", uri,
+ TUMBLER_ERROR, TUMBLER_ERROR_INVALID_FORMAT, error_msg);
g_free (error_msg);
/* clean up */
@@ -543,7 +547,8 @@ font_thumbnailer_create (TumblerAbstractThumbnailer *thumbnailer,
if (error != NULL)
{
/* emit an error signal */
- g_signal_emit_by_name (thumbnailer, "error", uri, error->code, error->message);
+ g_signal_emit_by_name (thumbnailer, "error", uri,
+ error->domain, error->code, error->message);
g_error_free (error);
}
else
diff --git a/plugins/gepub-thumbnailer/gepub-thumbnailer.c b/plugins/gepub-thumbnailer/gepub-thumbnailer.c
index 98062c7..9b65762 100644
--- a/plugins/gepub-thumbnailer/gepub-thumbnailer.c
+++ b/plugins/gepub-thumbnailer/gepub-thumbnailer.c
@@ -170,7 +170,7 @@ gepub_thumbnailer_create (TumblerAbstractThumbnailer *thumbnailer,
if (error != NULL)
{
g_signal_emit_by_name (thumbnailer, "error", uri,
- error->code, error->message);
+ error->domain, error->code, error->message);
g_error_free (error);
g_object_unref (file);
@@ -184,7 +184,7 @@ gepub_thumbnailer_create (TumblerAbstractThumbnailer *thumbnailer,
if (cover_mime == NULL)
{
g_signal_emit_by_name (thumbnailer, "error", uri,
- TUMBLER_ERROR_NO_CONTENT,
+ TUMBLER_ERROR, TUMBLER_ERROR_NO_CONTENT,
"Cover not found");
g_free (cover);
@@ -228,8 +228,8 @@ gepub_thumbnailer_create (TumblerAbstractThumbnailer *thumbnailer,
if (error != NULL)
{
- g_signal_emit_by_name (thumbnailer, "error", uri, error->code,
- error->message);
+ g_signal_emit_by_name (thumbnailer, "error", uri,
+ error->domain, error->code, error->message);
g_error_free (error);
}
else
diff --git a/plugins/gst-thumbnailer/gst-thumbnailer.c b/plugins/gst-thumbnailer/gst-thumbnailer.c
index d68a3cb..461471b 100644
--- a/plugins/gst-thumbnailer/gst-thumbnailer.c
+++ b/plugins/gst-thumbnailer/gst-thumbnailer.c
@@ -546,7 +546,8 @@ gst_thumbnailer_create (TumblerAbstractThumbnailer *thumbnailer,
/* there was an error, emit error signal */
g_set_error (&error, TUMBLER_ERROR, TUMBLER_ERROR_NO_CONTENT,
TUMBLER_ERROR_MESSAGE_CREATION_FAILED);
- g_signal_emit_by_name (thumbnailer, "error", uri, error->code, error->message);
+ g_signal_emit_by_name (thumbnailer, "error", uri,
+ error->domain, error->code, error->message);
g_error_free (error);
return;
@@ -607,7 +608,8 @@ gst_thumbnailer_create (TumblerAbstractThumbnailer *thumbnailer,
if (error != NULL)
{
- g_signal_emit_by_name (thumbnailer, "error", uri, error->code, error->message);
+ g_signal_emit_by_name (thumbnailer, "error", uri,
+ error->domain, error->code, error->message);
g_error_free (error);
}
else
@@ -622,7 +624,8 @@ gst_thumbnailer_create (TumblerAbstractThumbnailer *thumbnailer,
g_set_error (&error, TUMBLER_ERROR, TUMBLER_ERROR_NO_CONTENT,
TUMBLER_ERROR_MESSAGE_CREATION_FAILED);
- g_signal_emit_by_name (thumbnailer, "error", uri, error->code, error->message);
+ g_signal_emit_by_name (thumbnailer, "error", uri,
+ error->domain, error->code, error->message);
g_error_free (error);
}
diff --git a/plugins/jpeg-thumbnailer/jpeg-thumbnailer.c b/plugins/jpeg-thumbnailer/jpeg-thumbnailer.c
index bf5c0d3..9df8224 100644
--- a/plugins/jpeg-thumbnailer/jpeg-thumbnailer.c
+++ b/plugins/jpeg-thumbnailer/jpeg-thumbnailer.c
@@ -928,7 +928,8 @@ jpeg_thumbnailer_create (TumblerAbstractThumbnailer *thumbnailer,
if (error != NULL)
{
- g_signal_emit_by_name (thumbnailer, "error", uri, error->code, error->message);
+ g_signal_emit_by_name (thumbnailer, "error", uri,
+ error->domain, error->code, error->message);
g_error_free (error);
}
else
diff --git a/plugins/odf-thumbnailer/odf-thumbnailer.c b/plugins/odf-thumbnailer/odf-thumbnailer.c
index ff47bfc..7e62d1d 100644
--- a/plugins/odf-thumbnailer/odf-thumbnailer.c
+++ b/plugins/odf-thumbnailer/odf-thumbnailer.c
@@ -300,7 +300,8 @@ odf_thumbnailer_create (TumblerAbstractThumbnailer *thumbnailer,
input = gsf_input_gio_new (file, &error);
if (G_UNLIKELY (input == NULL))
{
- g_signal_emit_by_name (thumbnailer, "error", uri, error->code, error->message);
+ g_signal_emit_by_name (thumbnailer, "error", uri,
+ error->domain, error->code, error->message);
g_error_free (error);
g_object_unref (file);
return;
@@ -353,7 +354,8 @@ odf_thumbnailer_create (TumblerAbstractThumbnailer *thumbnailer,
if (error != NULL)
{
- g_signal_emit_by_name (thumbnailer, "error", uri, error->code, error->message);
+ g_signal_emit_by_name (thumbnailer, "error", uri,
+ error->domain, error->code, error->message);
g_error_free (error);
}
else
diff --git a/plugins/pixbuf-thumbnailer/pixbuf-thumbnailer.c b/plugins/pixbuf-thumbnailer/pixbuf-thumbnailer.c
index 6395d7f..8ee8364 100644
--- a/plugins/pixbuf-thumbnailer/pixbuf-thumbnailer.c
+++ b/plugins/pixbuf-thumbnailer/pixbuf-thumbnailer.c
@@ -218,8 +218,8 @@ pixbuf_thumbnailer_create (TumblerAbstractThumbnailer *thumbnailer,
if (stream == NULL)
{
- g_signal_emit_by_name (thumbnailer, "error", uri, error->code,
- error->message);
+ g_signal_emit_by_name (thumbnailer, "error", uri,
+ error->domain, error->code, error->message);
g_error_free (error);
return;
@@ -239,8 +239,8 @@ pixbuf_thumbnailer_create (TumblerAbstractThumbnailer *thumbnailer,
if (pixbuf == NULL)
{
- g_signal_emit_by_name (thumbnailer, "error", uri, error->code,
- error->message);
+ g_signal_emit_by_name (thumbnailer, "error", uri,
+ error->domain, error->code, error->message);
g_error_free (error);
g_object_unref (thumbnail);
@@ -263,7 +263,8 @@ pixbuf_thumbnailer_create (TumblerAbstractThumbnailer *thumbnailer,
if (error != NULL)
{
- g_signal_emit_by_name (thumbnailer, "error", uri, error->code, error->message);
+ g_signal_emit_by_name (thumbnailer, "error", uri,
+ error->domain, error->code, error->message);
g_error_free (error);
}
else
diff --git a/plugins/poppler-thumbnailer/poppler-thumbnailer.c b/plugins/poppler-thumbnailer/poppler-thumbnailer.c
index 8ee1083..e8aee20 100644
--- a/plugins/poppler-thumbnailer/poppler-thumbnailer.c
+++ b/plugins/poppler-thumbnailer/poppler-thumbnailer.c
@@ -259,7 +259,8 @@ poppler_thumbnailer_create (TumblerAbstractThumbnailer *thumbnailer,
/* try to load the file contents using GIO */
if (!g_file_load_contents (file, cancellable, &contents, &length, NULL, &error))
{
- g_signal_emit_by_name (thumbnailer, "error", uri, error->code, error->message);
+ g_signal_emit_by_name (thumbnailer, "error", uri,
+ error->domain, error->code, error->message);
g_error_free (error);
g_object_unref (file);
return;
@@ -281,7 +282,8 @@ poppler_thumbnailer_create (TumblerAbstractThumbnailer *thumbnailer,
/* emit an error if both ways to load the document failed */
if (document == NULL)
{
- g_signal_emit_by_name (thumbnailer, "error", uri, error->code, error->message);
+ g_signal_emit_by_name (thumbnailer, "error", uri,
+ error->domain, error->code, error->message);
g_error_free (error);
poppler_thumbnailer_free (contents);
return;
@@ -290,7 +292,8 @@ poppler_thumbnailer_create (TumblerAbstractThumbnailer *thumbnailer,
/* check if the document has content (= at least one page) */
if (poppler_document_get_n_pages (document) <= 0)
{
- g_signal_emit_by_name (thumbnailer, "error", uri, TUMBLER_ERROR_NO_CONTENT,
+ g_signal_emit_by_name (thumbnailer, "error", uri,
+ TUMBLER_ERROR, TUMBLER_ERROR_NO_CONTENT,
_("The document is empty"));
g_object_unref (document);
poppler_thumbnailer_free (contents);
@@ -302,7 +305,8 @@ poppler_thumbnailer_create (TumblerAbstractThumbnailer *thumbnailer,
if (page == NULL)
{
- g_signal_emit_by_name (thumbnailer, "error", uri, TUMBLER_ERROR_NO_CONTENT,
+ g_signal_emit_by_name (thumbnailer, "error", uri,
+ TUMBLER_ERROR, TUMBLER_ERROR_NO_CONTENT,
_("First page of the document could not be read"));
g_object_unref (document);
poppler_thumbnailer_free (contents);
@@ -353,7 +357,8 @@ poppler_thumbnailer_create (TumblerAbstractThumbnailer *thumbnailer,
if (error != NULL)
{
- g_signal_emit_by_name (thumbnailer, "error", uri, error->code, error->message);
+ g_signal_emit_by_name (thumbnailer, "error", uri,
+ error->domain, error->code, error->message);
g_error_free (error);
}
else
diff --git a/plugins/raw-thumbnailer/raw-thumbnailer.c b/plugins/raw-thumbnailer/raw-thumbnailer.c
index 92ac01d..962736a 100644
--- a/plugins/raw-thumbnailer/raw-thumbnailer.c
+++ b/plugins/raw-thumbnailer/raw-thumbnailer.c
@@ -178,7 +178,8 @@ raw_thumbnailer_create (TumblerAbstractThumbnailer *thumbnailer,
if (error != NULL)
{
- g_signal_emit_by_name (thumbnailer, "error", uri, error->code, error->message);
+ g_signal_emit_by_name (thumbnailer, "error", uri,
+ error->domain, error->code, error->message);
g_error_free (error);
}
else