Browse Source

HUE-6202 [assist] Fix js error from fetching locations

Johan Ahlen 8 years ago
parent
commit
42d2a7a707
1 changed files with 10 additions and 8 deletions
  1. 10 8
      desktop/core/src/desktop/static/desktop/js/ko.hue-bindings.js

+ 10 - 8
desktop/core/src/desktop/static/desktop/js/ko.hue-bindings.js

@@ -3493,15 +3493,17 @@
               }
             }
 
-            e.data.errors.forEach(function (error) {
-              if (error.expected.length > 0) {
-                var token = editor.session.getTokenAt(error.loc.first_line - 1, error.loc.first_column);
-                if (token) {
-                  token.error = error;
-                  editor.session.addMarker(new AceRange(error.loc.first_line - 1, error.loc.first_column, error.loc.last_line - 1, error.loc.last_column), 'hue-ace-error', 'fail');
+            if (e.data.errors) {
+              e.data.errors.forEach(function (error) {
+                if (error.expected.length > 0) {
+                  var token = editor.session.getTokenAt(error.loc.first_line - 1, error.loc.first_column);
+                  if (token) {
+                    token.error = error;
+                    editor.session.addMarker(new AceRange(error.loc.first_line - 1, error.loc.first_column, error.loc.last_line - 1, error.loc.last_column), 'hue-ace-error', 'fail');
+                  }
                 }
-              }
-            });
+              });
+            }
           }
 
           var lastKnownLocations = { id: $el.attr("id"), type: snippet.type(), defaultDatabase: snippet.database(), locations: e.data.locations };