[gnome-boxes] Don't pass GError::message directly to got_error



commit 1411ba951cf51443f4e4e26a0fa0ef0584585764
Author: Christophe Fergeau <cfergeau redhat com>
Date:   Mon Mar 4 11:48:14 2013 +0100

    Don't pass GError::message directly to got_error
    
    The error message stored in a GError generally comes from underlying
    libraries, and is not good enough to be shown to the user most of
    the time. This commit replaces uses of got_error with GError::message
    with more generic messages complemented by a debug() with the
    actual error message.
    
    I noticed this after getting a
    "Error connecting XXX: no free USB channel" in the UI when trying to
    redirect an USB device.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=695111

 src/libvirt-machine-properties.vala |   10 ++++++++--
 src/spice-display.vala              |   10 ++++++----
 2 files changed, 14 insertions(+), 6 deletions(-)
---
diff --git a/src/libvirt-machine-properties.vala b/src/libvirt-machine-properties.vala
index 677fcf0..1c697e3 100644
--- a/src/libvirt-machine-properties.vala
+++ b/src/libvirt-machine-properties.vala
@@ -253,7 +253,12 @@ private class Boxes.LibvirtMachineProperties: GLib.Object, Boxes.IPropertiesProv
                                         label.set_text (get_utf8_basename (path));
                                         empty = false;
                                     } catch (GLib.Error e) {
-                                        machine.got_error (e.message);
+                                        machine.got_error (_("Insertion of '%s' as a CD/DVD into '%s' 
failed").printf (get_utf8_basename (path),
+                                                                                                             
          machine.domain.get_name ()));
+                                        debug ("Error inserting '%s' as CD into '%s': %s",
+                                               get_utf8_basename (path),
+                                               machine.domain.get_name (),
+                                               e.message);
                                     }
                                 }
                                 dialog.destroy ();
@@ -267,7 +272,8 @@ private class Boxes.LibvirtMachineProperties: GLib.Object, Boxes.IPropertiesProv
                                 button_label.set_text (_("Select"));
                                 label.set_markup (Markup.printf_escaped ("<i>%s</i>", _("empty")));
                             } catch (GLib.Error e) {
-                                machine.got_error (e.message);
+                                machine.got_error (_("Removal of CD/DVD from '%s' failed").printf 
(machine.domain.get_name ()));
+                                debug ("Error ejecting CD from '%s': %s", machine.domain.get_name (), 
e.message);
                             }
                         }
                     });
diff --git a/src/spice-display.vala b/src/spice-display.vala
index ba4b6af..7e6a2f3 100644
--- a/src/spice-display.vala
+++ b/src/spice-display.vala
@@ -45,11 +45,13 @@ private class Boxes.SpiceDisplay: Boxes.Display {
         try {
             var manager = UsbDeviceManager.get (session);
             manager.auto_connect_failed.connect ( (dev, err) => {
-                    got_error (err.message);
+                    got_error (_("Automatic redirection of USB device '%s' failed").printf 
(dev.get_description ("%1$s %2$s")));
+                    debug ("Error auto-connecting %s: %s", dev.get_description ("%1$s %2$s"), err.message);
             });
 
             manager.device_error.connect ( (dev, err) => {
-                    got_error (err.message);
+                    got_error (_("Redirection of USB device '%s' failed").printf (dev.get_description ("%1$s 
%2$s")));
+                    debug ("Error connecting %s: %s", dev.get_description ("%1$s %2$s"), err.message);
             });
         } catch (GLib.Error error) {
         }
@@ -304,8 +306,8 @@ private class Boxes.SpiceDisplay: Boxes.Display {
                                             manager.connect_device_async.end (res);
                                         } catch (GLib.Error err) {
                                             dev_toggle.active = false;
-                                            got_error (_("Error connecting %s: %s").printf 
(dev.get_description ("%1$s %2$s"),
-                                                                                            err.message));
+                                            got_error (_("Redirection of USB device '%s' failed").printf 
(dev.get_description ("%1$s %2$s")));
+                                            debug ("Error connecting %s: %s", dev.get_description ("%1$s 
%2$s"), err.message);
                                         }
                                     });
                                 } else {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]