[gnome-ostree] builtin: Don't emit a useless stack trace when a builtin fails



commit 175cdae72e75bc5e64c9ef7c2f214746d6f54111
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Sun Sep 1 11:40:32 2013 -0400

    builtin: Don't emit a useless stack trace when a builtin fails

 src/js/builtin.js |   14 ++++++++++++--
 src/js/main.js    |    9 ++-------
 2 files changed, 14 insertions(+), 9 deletions(-)
---
diff --git a/src/js/builtin.js b/src/js/builtin.js
index 0c10e56..e353e94 100644
--- a/src/js/builtin.js
+++ b/src/js/builtin.js
@@ -73,7 +73,17 @@ const Builtin = new Lang.Class({
     },
 
     main: function(argv, loop, cancellable) {
-       let args = this.parser.parse(argv);
-       this.execute(args, loop, cancellable);
+        let result;
+        try {
+           let args = this.parser.parse(argv);
+            result = this.execute(args, loop, cancellable);
+        } catch(e) {
+            log(e.message);
+            return 1;
+        }
+
+        if (result === undefined)
+            return 0;
+        return result;
     }
 });
diff --git a/src/js/main.js b/src/js/main.js
index e089d32..212b989 100644
--- a/src/js/main.js
+++ b/src/js/main.js
@@ -76,13 +76,8 @@ if (ARGV.length < 1) {
        let cancellable = null;
        GLib.idle_add(GLib.PRIORITY_DEFAULT,
                      function() {
-                         ecode = 1;
-                         try {
-                             instance.main(argv, loop, cancellable);
-                             ecode = 0;
-                         } finally {
-                             loop.quit();
-                         }
+                         ecode = instance.main(argv, loop, cancellable);
+                          loop.quit();
                          return false;
                      });
        loop.run();


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