[gnome-builder/wip/gjs-indexer-robustness: 6/7] gjs_symbols: Catch all gjs exceptions to avoid criticals



commit 5b26eb1795595975ef93e74750e8114cbd0b4c9e
Author: Patrick Griffis <tingping tingping se>
Date:   Sat Apr 4 09:34:06 2020 -0700

    gjs_symbols: Catch all gjs exceptions to avoid criticals

 src/plugins/gjs-symbols/gjs_symbols.py | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)
---
diff --git a/src/plugins/gjs-symbols/gjs_symbols.py b/src/plugins/gjs-symbols/gjs_symbols.py
index 26e19c7a8..b96de08cc 100644
--- a/src/plugins/gjs-symbols/gjs_symbols.py
+++ b/src/plugins/gjs-symbols/gjs_symbols.py
@@ -242,14 +242,19 @@ class JsSymbolTree(GObject.Object, Ide.SymbolTree):
 
 JS_SCRIPT = \
 """var data;
-if (ARGV[0] === '--file') {
-  const GLib = imports.gi.GLib;
-  var ret = GLib.file_get_contents(ARGV[1]);
-  data = ret[1];
-} else {
-  data = ARGV[0];
+try {
+    if (ARGV[0] === '--file') {
+        const GLib = imports.gi.GLib;
+        var ret = GLib.file_get_contents(ARGV[1]);
+        data = ret[1];
+    } else {
+        data = ARGV[0];
+    }
+    print(JSON.stringify(Reflect.parse(data, {source: '%s'})));
+} catch (e) {
+    imports.system.exit(1);
 }
-print(JSON.stringify(Reflect.parse(data, {source: '%s'})));""".replace('\n', ' ')
+""".replace('\n', ' ')
 
 
 class GjsSymbolProvider(Ide.Object, Ide.SymbolResolver):


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