diff options
author | Pavel Grunt <pgrunt@redhat.com> | 2015-03-20 10:35:56 +0100 |
---|---|---|
committer | Fabiano FidĂȘncio <fidencio@redhat.com> | 2015-03-23 19:32:02 +0100 |
commit | 1a619f23835abcc358b84bcead14171361907038 (patch) | |
tree | 0ea1656197ea266863951dbddc736a254b0ac655 /src/virt-viewer.c | |
parent | 526e882368eb74eb1ed9de5c1c8aefb7b428fb9d (diff) | |
download | virt-viewer-1a619f23835abcc358b84bcead14171361907038.tar.gz virt-viewer-1a619f23835abcc358b84bcead14171361907038.tar.xz virt-viewer-1a619f23835abcc358b84bcead14171361907038.zip |
Report errors in one place
Since the error is propagated to the main, report the error there.
To make it work GError VIRT_VIEWER_ERROR_FAILED is set for all
failing states and it is reported using virt_viewer_app_simple_message_dialog().
Diffstat (limited to 'src/virt-viewer.c')
-rw-r--r-- | src/virt-viewer.c | 21 |
1 files changed, 4 insertions, 17 deletions
diff --git a/src/virt-viewer.c b/src/virt-viewer.c index 371bf4a..49e8923 100644 --- a/src/virt-viewer.c +++ b/src/virt-viewer.c @@ -746,7 +746,9 @@ virt_viewer_initial_connect(VirtViewerApp *app, GError **error) virt_viewer_app_show_status(app, _("Checking guest domain status")); if (virDomainGetInfo(dom, &info) < 0) { - g_debug("Cannot get guest state"); + g_set_error_literal(&err, VIRT_VIEWER_ERROR, VIRT_VIEWER_ERROR_FAILED, + _("Cannot get guest state")); + g_debug("%s", err->message); goto cleanup; } @@ -911,7 +913,6 @@ virt_viewer_connect(VirtViewerApp *app, GError **err) g_set_error_literal(&error, VIRT_VIEWER_ERROR, VIRT_VIEWER_ERROR_FAILED, error_message); - virt_viewer_app_simple_message_dialog(app, error_message); g_free(error_message); } else { @@ -924,21 +925,7 @@ virt_viewer_connect(VirtViewerApp *app, GError **err) } if (!virt_viewer_app_initial_connect(app, &error)) { - if (error != NULL) { - if (!g_error_matches(error, VIRT_VIEWER_ERROR, VIRT_VIEWER_ERROR_CANCELLED)) { - VirtViewerWindow *main_window = virt_viewer_app_get_main_window(app); - - GtkWidget *dialog = gtk_message_dialog_new(virt_viewer_window_get_window(main_window), - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, - GTK_BUTTONS_CLOSE, - "Failed to connect: %s", - error->message); - gtk_dialog_run(GTK_DIALOG(dialog)); - gtk_widget_destroy(GTK_WIDGET(dialog)); - } - g_propagate_error(err, error); - } + g_propagate_prefixed_error(err, error, _("Failed to connect: ")); return -1; } |