[virt-tools-list] [virt-viewer] vnc: Report error on virt_viewer_session_vnc_open_uri() failures
Christophe Fergeau
cfergeau at redhat.com
Tue Dec 13 10:30:57 UTC 2016
For example this changes the error message for 'vnc:foo:1' from
"Failed to initiate connection" to "Invalid VNC URI: 'vnc:foo:1'"
---
src/virt-viewer-session-vnc.c | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/src/virt-viewer-session-vnc.c b/src/virt-viewer-session-vnc.c
index 5cd20af..18ccc4a 100644
--- a/src/virt-viewer-session-vnc.c
+++ b/src/virt-viewer-session-vnc.c
@@ -30,6 +30,7 @@
#include "virt-viewer-auth.h"
#include "virt-viewer-session-vnc.h"
#include "virt-viewer-display-vnc.h"
+#include "virt-viewer-util.h"
#include <glib/gi18n.h>
#include <libxml/uri.h>
@@ -227,12 +228,20 @@ virt_viewer_session_vnc_open_uri(VirtViewerSession* session,
portstr = g_strdup_printf("%d", virt_viewer_file_get_port(file));
hoststr = g_strdup(virt_viewer_file_get_host(file));
- if (!virt_viewer_file_fill_app(file, app, error))
+ if (!virt_viewer_file_fill_app(file, app, error)) {
+ g_set_error(error,
+ VIRT_VIEWER_ERROR, VIRT_VIEWER_ERROR_FAILED,
+ _("Failed to parse connection file"));
return FALSE;
+ }
} else {
xmlURIPtr uri = NULL;
- if (!(uri = xmlParseURI(uristr)))
+ if (!(uri = xmlParseURI(uristr))) {
+ g_set_error(error,
+ VIRT_VIEWER_ERROR, VIRT_VIEWER_ERROR_FAILED,
+ _("Failed to parse VNC URI '%s'"), uristr);
return FALSE;
+ }
portstr = g_strdup_printf("%d", uri->port);
@@ -254,7 +263,12 @@ virt_viewer_session_vnc_open_uri(VirtViewerSession* session,
ret = vnc_display_open_host(self->priv->vnc,
hoststr,
portstr);
+ } else {
+ g_set_error(error,
+ VIRT_VIEWER_ERROR, VIRT_VIEWER_ERROR_FAILED,
+ _("Invalid VNC URI '%s'"), uristr);
}
+
g_free(portstr);
g_free(hoststr);
return ret;
--
2.9.3
More information about the virt-tools-list
mailing list