After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 684224 - Add error handling to Machine::connect_display
Add error handling to Machine::connect_display
Status: RESOLVED FIXED
Product: gnome-boxes
Classification: Applications
Component: general
unspecified
Other All
: Normal normal
: --
Assigned To: GNOME Boxes maintainer(s)
GNOME Boxes maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2012-09-17 14:55 UTC by Christophe Fergeau
Modified: 2016-03-31 13:59 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Allow Machine::connect_display to report errors (3.26 KB, patch)
2012-09-17 14:55 UTC, Christophe Fergeau
none Details | Review
Make LibvirtMachine::start private (795 bytes, patch)
2012-09-17 14:55 UTC, Christophe Fergeau
none Details | Review
Allow LibvirtMachine::start to throw exceptions (2.40 KB, patch)
2012-09-17 14:55 UTC, Christophe Fergeau
none Details | Review
Throw errors from Libvirt::update_display (1.52 KB, patch)
2012-09-17 14:55 UTC, Christophe Fergeau
none Details | Review
Allow Display::connect_it to throw errors (2.12 KB, patch)
2012-09-17 14:55 UTC, Christophe Fergeau
none Details | Review
Don't silently ignore errors in ::connect_it impl (3.43 KB, patch)
2012-09-17 14:56 UTC, Christophe Fergeau
needs-work Details | Review
Allow Display::connect_it to throw errors (2.12 KB, patch)
2012-09-18 09:36 UTC, Christophe Fergeau
none Details | Review
Don't silently ignore errors in ::connect_it impl (1.39 KB, patch)
2012-09-18 09:36 UTC, Christophe Fergeau
none Details | Review
SpiceDisplay::get_display cannot throw (5.50 KB, patch)
2012-09-18 09:36 UTC, Christophe Fergeau
none Details | Review
Allow Machine::connect_display to report errors (3.14 KB, patch)
2012-09-18 10:01 UTC, Christophe Fergeau
committed Details | Review
Make LibvirtMachine::start private (795 bytes, patch)
2012-09-18 10:01 UTC, Christophe Fergeau
committed Details | Review
Allow LibvirtMachine::start to throw exceptions (3.06 KB, patch)
2012-09-18 10:01 UTC, Christophe Fergeau
committed Details | Review
Throw errors from Libvirt::update_display (1.52 KB, patch)
2012-09-18 10:01 UTC, Christophe Fergeau
committed Details | Review
Allow Display::connect_it to throw errors (2.12 KB, patch)
2012-09-18 10:01 UTC, Christophe Fergeau
committed Details | Review
Don't silently ignore errors in ::connect_it impl (1.39 KB, patch)
2012-09-18 10:01 UTC, Christophe Fergeau
committed Details | Review
SpiceDisplay::get_display cannot throw (5.50 KB, patch)
2012-09-18 10:02 UTC, Christophe Fergeau
committed Details | Review
Add error popup on box connection errors (1.37 KB, patch)
2012-09-18 10:02 UTC, Christophe Fergeau
none Details | Review
Add error popup on box connection errors (1.50 KB, patch)
2012-09-18 11:02 UTC, Christophe Fergeau
committed Details | Review

Description Christophe Fergeau 2012-09-17 14:55:43 UTC
Currently, when the user clicks on a box to connect to it, if the connection
fails for some reason, there is no feedback at all. The UI seems to be frozen
on a zoomed in thumbnail. The user can go back to the collection view,
but that makes the user experience weird.
This patch adds a way for ::connect_display to report errors so that we can
switch back to the collection view and display an error popup.
May be risky for 3.5.92 though, and needs a string freeze break approval...
Comment 1 Christophe Fergeau 2012-09-17 14:55:46 UTC
Created attachment 224516 [details] [review]
Allow Machine::connect_display to report errors

If an error occurs while we connect to a remote display, we
currently have no way of reporting this to the user. When
this happens, Boxes is stuck on showing a zoomed in box snapshot
in the middle of the screen, and nothing else happens.
This commit allows Machine::connect_display to throw exceptions, and
catches them to report errors. However, this is just preparatory work
as the various Machine::connect_display needs to be modified to actually
report the errors they encounter.
Comment 2 Christophe Fergeau 2012-09-17 14:55:49 UTC
Created attachment 224517 [details] [review]
Make LibvirtMachine::start private

It's only used in LibvirtMachine.
Comment 3 Christophe Fergeau 2012-09-17 14:55:51 UTC
Created attachment 224518 [details] [review]
Allow LibvirtMachine::start to throw exceptions

It's only used in two places, once in connect_display() where we
want to get an exception when something happens, and once in
notify_reboot_required() where only .begin() is called, so this does
not change behaviour as the exception would be reported when calling
.end()
Comment 4 Christophe Fergeau 2012-09-17 14:55:54 UTC
Created attachment 224519 [details] [review]
Throw errors from Libvirt::update_display

We want LibvirtMachine::connect_display to be able to report
connection errors.
Comment 5 Christophe Fergeau 2012-09-17 14:55:58 UTC
Created attachment 224520 [details] [review]
Allow Display::connect_it to throw errors

It's only called from Machine::connect_display overrides from
where we want to be able to forward connection errors to the caller.
Comment 6 Christophe Fergeau 2012-09-17 14:56:00 UTC
Created attachment 224521 [details] [review]
Don't silently ignore errors in ::connect_it impl
Comment 7 Christophe Fergeau 2012-09-17 19:46:06 UTC
(In reply to comment #0)
> May be risky for 3.5.92 though, and needs a string freeze break approval...

The break is a new string in the first patch: _("Connection to '%s' failed")
Comment 8 Alexander Larsson 2012-09-18 08:53:32 UTC
Review of attachment 224521 [details] [review]:

::: src/spice-display.vala
@@ +151,3 @@
                                 hide (display.channel_id);
                         });
+                    } catch (Boxes.Error error) { rethrow_error = error; warning (error.message); }

This doesn't seem right. You can't just set the rethrow_error local variable from a callback, the original call might have exited a long time ago already.

@@ +166,3 @@
+            session.password = password;
+            session.connect ();
+        } catch (GLib.Error error) {

Same here, any error in the channel_destroy callback is not gonna be reported to the connect_it caller.
Comment 9 Alexander Larsson 2012-09-18 08:55:11 UTC
I agree that this is important, getting stuck on error isn't very robust...
Comment 10 Christophe Fergeau 2012-09-18 09:36:14 UTC
Created attachment 224584 [details] [review]
Allow Display::connect_it to throw errors

It's only called from Machine::connect_display overrides from
where we want to be able to forward connection errors to the caller.
Comment 11 Christophe Fergeau 2012-09-18 09:36:16 UTC
Created attachment 224585 [details] [review]
Don't silently ignore errors in ::connect_it impl
Comment 12 Christophe Fergeau 2012-09-18 09:36:18 UTC
Created attachment 224586 [details] [review]
SpiceDisplay::get_display cannot throw

Spice::get_display() throws an exception when spice_display_new returns
null. However, this function is a wrapper over g_object_new so it cannot
return null. We can thus mark Spice::get_display() as not throwing, and
update its callers accordingly.
Comment 13 Christophe Fergeau 2012-09-18 09:38:44 UTC
Review of attachment 224521 [details] [review]:

::: src/spice-display.vala
@@ +151,3 @@
                                 hide (display.channel_id);
                         });
+                    } catch (Boxes.Error error) { rethrow_error = error; warning (error.message); }

Oops, thanks for the catch, dunno what I was thinking ;)
On closer look, it appears that get_display can never throw, so it's possible to clean up all of this, see updated patches

@@ +166,3 @@
+            session.password = password;
+            session.connect ();
+        } catch (GLib.Error error) {

Yeah, this is useless anyway as vala tells me that nothing can throw in this code block, I've killed it.
Comment 14 Alexander Larsson 2012-09-18 09:47:17 UTC
Review of attachment 224518 [details] [review]:

::: src/libvirt-machine.vala
@@ -573,3 @@
-            }
-        } catch (GLib.Error error) {
-            warning ("Failed to start '%s': %s", domain.get_name (), error.message);

If you're not calling .end in the other case, we lose this warning though?
Comment 15 Christophe Fergeau 2012-09-18 10:01:45 UTC
Created attachment 224588 [details] [review]
Allow Machine::connect_display to report errors

If an error occurs while we connect to a remote display, we
currently have no way of reporting this to the user. When
this happens, Boxes is stuck on showing a zoomed in box snapshot
in the middle of the screen, and nothing else happens.
This commit allows Machine::connect_display to throw exceptions, and
catches them to report errors. However, this is just preparatory work
as the various Machine::connect_display needs to be modified to actually
report the errors they encounter.
Comment 16 Christophe Fergeau 2012-09-18 10:01:47 UTC
Created attachment 224589 [details] [review]
Make LibvirtMachine::start private

It's only used in LibvirtMachine.
Comment 17 Christophe Fergeau 2012-09-18 10:01:50 UTC
Created attachment 224590 [details] [review]
Allow LibvirtMachine::start to throw exceptions

It's only used in two places, once in connect_display() where we
want to get an exception when something happens, and once in
notify_reboot_required() where only .begin() is called, so this does
not change behaviour as the exception would be reported when calling
.end()
Comment 18 Christophe Fergeau 2012-09-18 10:01:53 UTC
Created attachment 224591 [details] [review]
Throw errors from Libvirt::update_display

We want LibvirtMachine::connect_display to be able to report
connection errors.
Comment 19 Christophe Fergeau 2012-09-18 10:01:55 UTC
Created attachment 224592 [details] [review]
Allow Display::connect_it to throw errors

It's only called from Machine::connect_display overrides from
where we want to be able to forward connection errors to the caller.
Comment 20 Christophe Fergeau 2012-09-18 10:01:58 UTC
Created attachment 224593 [details] [review]
Don't silently ignore errors in ::connect_it impl
Comment 21 Christophe Fergeau 2012-09-18 10:02:02 UTC
Created attachment 224594 [details] [review]
SpiceDisplay::get_display cannot throw

Spice::get_display() throws an exception when spice_display_new returns
null. However, this function is a wrapper over g_object_new so it cannot
return null. We can thus mark Spice::get_display() as not throwing, and
update its callers accordingly.
Comment 22 Christophe Fergeau 2012-09-18 10:02:05 UTC
Created attachment 224595 [details] [review]
Add error popup on box connection errors

This commit adds a new string and we are in string freeze break,
so approval is needed to get this change in. However, the patch
series is still a good improvement even without the added string,
so I'm splitting this out to be able to commit the rest of the series
(thanks Alex for the suggestion!).
However, without this error message, Boxes starting to connect to a box
and then giving up can be quite confusing, so adding this message
is a worthwhile user-friendliness improvement.
Comment 23 Christophe Fergeau 2012-09-18 10:04:37 UTC
Here is a rediffed series with the string breaking the freeze split in a separate commit, and with the warning readded in commit "Allow LibvirtMachine::start to throw exceptions"
Comment 24 Alexander Larsson 2012-09-18 10:43:38 UTC
Review of attachment 224588 [details] [review]:

ok
Comment 25 Alexander Larsson 2012-09-18 10:43:48 UTC
Review of attachment 224589 [details] [review]:

ok
Comment 26 Alexander Larsson 2012-09-18 10:44:29 UTC
Review of attachment 224590 [details] [review]:

ok
Comment 27 Alexander Larsson 2012-09-18 10:44:48 UTC
Review of attachment 224591 [details] [review]:

ok
Comment 28 Alexander Larsson 2012-09-18 10:45:06 UTC
Review of attachment 224592 [details] [review]:

ok
Comment 29 Alexander Larsson 2012-09-18 10:45:17 UTC
Review of attachment 224593 [details] [review]:

ok
Comment 30 Alexander Larsson 2012-09-18 10:46:28 UTC
Review of attachment 224594 [details] [review]:

ok
Comment 31 Alexander Larsson 2012-09-18 10:49:13 UTC
Review of attachment 224595 [details] [review]:

::: src/app.vala
@@ +695,1 @@
                         warning ("connect display failed: %s", e.message);

Should also remove warning?
Comment 32 Christophe Fergeau 2012-09-18 11:00:58 UTC
Review of attachment 224595 [details] [review]:

::: src/app.vala
@@ +695,1 @@
                         warning ("connect display failed: %s", e.message);

I'll move it to debug(), error.message can be useful while debugging.
Comment 33 Christophe Fergeau 2012-09-18 11:02:20 UTC
Created attachment 224605 [details] [review]
Add error popup on box connection errors

This commit adds a new string and we are in string freeze break,
so approval is needed to get this change in. However, the patch
series is still a good improvement even without the added string,
so I'm splitting this out to be able to commit the rest of the series
(thanks Alex for the suggestion!).
However, without this error message, Boxes starting to connect to a box
and then giving up can be quite confusing, so adding this message
is a worthwhile user-friendliness improvement.
Comment 34 Christophe Fergeau 2012-09-18 11:03:39 UTC
Attachment 224588 [details] pushed as 8745a86 - Allow Machine::connect_display to report errors
Attachment 224589 [details] pushed as 07e4d67 - Make LibvirtMachine::start private
Attachment 224590 [details] pushed as 7aeeb81 - Allow LibvirtMachine::start to throw exceptions
Attachment 224591 [details] pushed as 5aa069b - Throw errors from Libvirt::update_display
Attachment 224592 [details] pushed as 49cbb6f - Allow Display::connect_it to throw errors
Attachment 224593 [details] pushed as 7843467 - Don't silently ignore errors in ::connect_it impl
Attachment 224594 [details] pushed as 313c482 - SpiceDisplay::get_display cannot throw
Comment 35 Christophe Fergeau 2012-09-19 08:10:06 UTC
Comment on attachment 224605 [details] [review]
Add error popup on box connection errors

Got 2 ACKs from gnome-i18n, patch pushed before 3.5.92