[gnome-software] shell: Improve the logic when to show detailed error messages
- From: Kalev Lember <klember src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] shell: Improve the logic when to show detailed error messages
- Date: Wed, 16 Jan 2019 18:48:49 +0000 (UTC)
commit 5afe6403da06fbe4060ed9ff004a347c51295029
Author: Kalev Lember <klember redhat com>
Date: Tue Jan 15 23:55:22 2019 +0100
shell: Improve the logic when to show detailed error messages
Make sure we never have "Sorry, something went wrong" without actual
details what went wrong.
src/gs-shell.c | 64 +++++++++++++---------------------------------------------
1 file changed, 14 insertions(+), 50 deletions(-)
---
diff --git a/src/gs-shell.c b/src/gs-shell.c
index e1e2b8c4..ac8cf2f7 100644
--- a/src/gs-shell.c
+++ b/src/gs-shell.c
@@ -960,16 +960,6 @@ gs_shell_get_title_from_app (GsApp *app)
return g_strdup_printf (_("ā%sā"), gs_app_get_id (app));
}
-static gboolean
-gs_shell_show_detailed_error (GsShell *shell, const GError *error)
-{
- if (error->code == GS_PLUGIN_ERROR_FAILED)
- return TRUE;
- if (error->code == GS_PLUGIN_ERROR_DOWNLOAD_FAILED)
- return TRUE;
- return FALSE;
-}
-
static gchar *
get_first_line (const gchar *str)
{
@@ -1025,6 +1015,7 @@ gs_shell_show_event_refresh (GsShell *shell, GsPluginEvent *event)
/* TRANSLATORS: failure text for the in-app notification */
g_string_append (str, _("Unable to download updates"));
}
+ gs_shell_append_detailed_error (shell, str, error);
break;
case GS_PLUGIN_ERROR_NO_NETWORK:
/* TRANSLATORS: failure text for the in-app notification */
@@ -1075,6 +1066,7 @@ gs_shell_show_event_refresh (GsShell *shell, GsPluginEvent *event)
/* TRANSLATORS: failure text for the in-app notification */
g_string_append (str, _("Unable to get list of updates"));
}
+ gs_shell_append_detailed_error (shell, str, error);
break;
}
if (str->len == 0)
@@ -1090,10 +1082,6 @@ gs_shell_show_event_refresh (GsShell *shell, GsPluginEvent *event)
}
}
- /* add extra debugging for debug builds */
- if (gs_shell_show_detailed_error (shell, error))
- gs_shell_append_detailed_error (shell, str, error);
-
/* show in-app notification */
gs_shell_show_event_app_notify (shell, str->str, buttons);
return TRUE;
@@ -1141,15 +1129,12 @@ gs_shell_show_event_purchase (GsShell *shell, GsPluginEvent *event)
/* TRANSLATORS: failure text for the in-app notification,
* where the %s is the application name (e.g. "GIMP") */
g_string_append_printf (str, _("Unable to purchase %s"), str_app);
+ gs_shell_append_detailed_error (shell, str, error);
break;
}
if (str->len == 0)
return FALSE;
- /* add extra debugging for debug builds */
- if (gs_shell_show_detailed_error (shell, error))
- gs_shell_append_detailed_error (shell, str, error);
-
/* show in-app notification */
gs_shell_show_event_app_notify (shell, str->str, GS_SHELL_EVENT_BUTTON_NONE);
return TRUE;
@@ -1186,6 +1171,7 @@ gs_shell_show_event_install (GsShell *shell, GsPluginEvent *event)
"as download failed"),
str_app);
}
+ gs_shell_append_detailed_error (shell, str, error);
break;
case GS_PLUGIN_ERROR_NOT_SUPPORTED:
if (origin != NULL) {
@@ -1257,6 +1243,7 @@ gs_shell_show_event_install (GsShell *shell, GsPluginEvent *event)
/* TRANSLATORS: failure text for the in-app notification,
* where the %s is the application name (e.g. "GIMP") */
g_string_append_printf (str, _("Unable to install %s"), str_app);
+ gs_shell_append_detailed_error (shell, str, error);
break;
}
if (str->len == 0)
@@ -1272,10 +1259,6 @@ gs_shell_show_event_install (GsShell *shell, GsPluginEvent *event)
}
}
- /* add extra debugging for debug builds */
- if (gs_shell_show_detailed_error (shell, error))
- gs_shell_append_detailed_error (shell, str, error);
-
/* show in-app notification */
gs_shell_show_event_app_notify (shell, str->str, buttons);
return TRUE;
@@ -1322,6 +1305,7 @@ gs_shell_show_event_update (GsShell *shell, GsPluginEvent *event)
/* TRANSLATORS: failure text for the in-app notification */
g_string_append_printf (str, _("Unable to install updates as download failed"));
}
+ gs_shell_append_detailed_error (shell, str, error);
break;
case GS_PLUGIN_ERROR_NO_NETWORK:
/* TRANSLATORS: failure text for the in-app notification */
@@ -1416,6 +1400,7 @@ gs_shell_show_event_update (GsShell *shell, GsPluginEvent *event)
/* TRANSLATORS: failure text for the in-app notification */
g_string_append_printf (str, _("Unable to install updates"));
}
+ gs_shell_append_detailed_error (shell, str, error);
break;
}
if (str->len == 0)
@@ -1431,10 +1416,6 @@ gs_shell_show_event_update (GsShell *shell, GsPluginEvent *event)
}
}
- /* add extra debugging for debug builds */
- if (gs_shell_show_detailed_error (shell, error))
- gs_shell_append_detailed_error (shell, str, error);
-
/* show in-app notification */
gs_shell_show_event_app_notify (shell, str->str, buttons);
return TRUE;
@@ -1469,6 +1450,7 @@ gs_shell_show_event_upgrade (GsShell *shell, GsPluginEvent *event)
"as download failed"),
str_app);
}
+ gs_shell_append_detailed_error (shell, str, error);
break;
case GS_PLUGIN_ERROR_NO_NETWORK:
/* TRANSLATORS: failure text for the in-app notification,
@@ -1521,6 +1503,7 @@ gs_shell_show_event_upgrade (GsShell *shell, GsPluginEvent *event)
/* TRANSLATORS: failure text for the in-app notification,
* where the %s is the distro name (e.g. "Fedora 25") */
g_string_append_printf (str, _("Unable to upgrade to %s"), str_app);
+ gs_shell_append_detailed_error (shell, str, error);
break;
}
if (str->len == 0)
@@ -1536,10 +1519,6 @@ gs_shell_show_event_upgrade (GsShell *shell, GsPluginEvent *event)
}
}
- /* add extra debugging for debug builds */
- if (gs_shell_show_detailed_error (shell, error))
- gs_shell_append_detailed_error (shell, str, error);
-
/* show in-app notification */
gs_shell_show_event_app_notify (shell, str->str, buttons);
return TRUE;
@@ -1593,6 +1572,7 @@ gs_shell_show_event_remove (GsShell *shell, GsPluginEvent *event)
/* TRANSLATORS: failure text for the in-app notification,
* where the %s is the application name (e.g. "GIMP") */
g_string_append_printf (str, _("Unable to remove %s"), str_app);
+ gs_shell_append_detailed_error (shell, str, error);
break;
}
if (str->len == 0)
@@ -1608,10 +1588,6 @@ gs_shell_show_event_remove (GsShell *shell, GsPluginEvent *event)
}
}
- /* add extra debugging for debug builds */
- if (gs_shell_show_detailed_error (shell, error))
- gs_shell_append_detailed_error (shell, str, error);
-
/* show in-app notification */
gs_shell_show_event_app_notify (shell, str->str, buttons);
return TRUE;
@@ -1657,6 +1633,7 @@ gs_shell_show_event_launch (GsShell *shell, GsPluginEvent *event)
return FALSE;
/* TRANSLATORS: we failed to get a proper error code */
g_string_append (str, _("Sorry, something went wrong"));
+ gs_shell_append_detailed_error (shell, str, error);
break;
}
if (str->len == 0)
@@ -1672,10 +1649,6 @@ gs_shell_show_event_launch (GsShell *shell, GsPluginEvent *event)
}
}
- /* add extra debugging for debug builds */
- if (gs_shell_show_detailed_error (shell, error))
- gs_shell_append_detailed_error (shell, str, error);
-
/* show in-app notification */
gs_shell_show_event_app_notify (shell, str->str, buttons);
return TRUE;
@@ -1711,15 +1684,12 @@ gs_shell_show_event_file_to_app (GsShell *shell, GsPluginEvent *event)
return FALSE;
/* TRANSLATORS: we failed to get a proper error code */
g_string_append (str, _("Sorry, something went wrong"));
+ gs_shell_append_detailed_error (shell, str, error);
break;
}
if (str->len == 0)
return FALSE;
- /* add extra debugging for debug builds */
- if (gs_shell_show_detailed_error (shell, error))
- gs_shell_append_detailed_error (shell, str, error);
-
/* show in-app notification */
gs_shell_show_event_app_notify (shell, str->str, buttons);
return TRUE;
@@ -1755,15 +1725,12 @@ gs_shell_show_event_url_to_app (GsShell *shell, GsPluginEvent *event)
return FALSE;
/* TRANSLATORS: we failed to get a proper error code */
g_string_append (str, _("Sorry, something went wrong"));
+ gs_shell_append_detailed_error (shell, str, error);
break;
}
if (str->len == 0)
return FALSE;
- /* add extra debugging for debug builds */
- if (gs_shell_show_detailed_error (shell, error))
- g_string_append_printf (str, "\n%s", error->message);
-
/* show in-app notification */
gs_shell_show_event_app_notify (shell, str->str, buttons);
return TRUE;
@@ -1825,6 +1792,7 @@ gs_shell_show_event_fallback (GsShell *shell, GsPluginEvent *event)
return FALSE;
/* TRANSLATORS: we failed to get a proper error code */
g_string_append (str, _("Sorry, something went wrong"));
+ gs_shell_append_detailed_error (shell, str, error);
break;
}
if (str->len == 0)
@@ -1840,10 +1808,6 @@ gs_shell_show_event_fallback (GsShell *shell, GsPluginEvent *event)
}
}
- /* add extra debugging for debug builds */
- if (gs_shell_show_detailed_error (shell, error))
- gs_shell_append_detailed_error (shell, str, error);
-
/* show in-app notification */
gs_shell_show_event_app_notify (shell, str->str, buttons);
return TRUE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]