[gnome-boxes] wizard: Properly handle errors on 'prepare' & 'create'



commit 2502424c59489c1f055ad22ca8f090d932bff480
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Tue Jan 31 18:41:47 2012 +0200

    wizard: Properly handle errors on 'prepare' & 'create'
    
    Display an error in notification and in case of 'prepare', we go back to
    previous step since user is very likely to be able to fix the issue.
    
    The error message displayed at failure from 'create' is not very useful
    but we don't want to show cryptic error messages to user and we really
    should aim to make it (almost) impossible to get errors from 'create'.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=668792

 src/wizard.vala |   15 +++++++++------
 1 files changed, 9 insertions(+), 6 deletions(-)
---
diff --git a/src/wizard.vala b/src/wizard.vala
index dc1f753..0c44a3b 100644
--- a/src/wizard.vala
+++ b/src/wizard.vala
@@ -55,7 +55,7 @@ private class Boxes.Wizard: Boxes.UI {
                     try {
                         prepare ();
                     } catch (GLib.Error error) {
-                        warning ("Fixme: %s".printf (error.message));
+                        app.notificationbar.display_error (error.message);
                         return;
                     }
                     break;
@@ -71,8 +71,10 @@ private class Boxes.Wizard: Boxes.UI {
 
                 case WizardPage.LAST:
                     create.begin ((source, result) => {
-                       if (create.end (result))
-                           app.ui_state = UIState.COLLECTION;
+                        if (create.end (result))
+                            app.ui_state = UIState.COLLECTION;
+                        else
+                            app.notificationbar.display_error (_("Box creation failed!"));
                     });
                     return;
                 }
@@ -195,7 +197,7 @@ private class Boxes.Wizard: Boxes.UI {
         var uri = Xml.URI.parse (uri_as_text);
 
         if (uri == null)
-            throw new Boxes.Error.INVALID ("the URI is invalid");
+            throw new Boxes.Error.INVALID (_("Invalid URI"));
 
         source = new CollectionSource (uri.server ?? uri_as_text, uri.scheme, uri_as_text);
 
@@ -206,7 +208,7 @@ private class Boxes.Wizard: Boxes.UI {
             // accept any qemu..:// uri
             source.source_type = "libvirt";
         } else
-            throw new Boxes.Error.INVALID ("Unsupported protocol %s".printf (uri.scheme));
+            throw new Boxes.Error.INVALID (_("Unsupported protocol '%s'").printf (uri.scheme));
     }
 
     private void prepare_for_installer (string path) throws GLib.Error {
@@ -223,7 +225,8 @@ private class Boxes.Wizard: Boxes.UI {
             page = page + 1;
         } catch (IOError.CANCELLED cancel_error) { // We did this, so no warning!
         } catch (GLib.Error error) {
-            warning ("Fixme: %s".printf (error.message));
+            app.notificationbar.display_error (error.message);
+            page = page - 1;
         }
     }
 



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