Explorar o código

Fix JS compilation error display

Sebastien Lebreton %!s(int64=5) %!d(string=hai) anos
pai
achega
c8034b1eeb
Modificáronse 2 ficheiros con 10 adicións e 6 borrados
  1. 9 4
      Playground/js/main.js
  2. 1 2
      Playground/js/monacoCreator.js

+ 9 - 4
Playground/js/main.js

@@ -1,5 +1,11 @@
 var engine = null;
 
+handleException = function(parent, e) {
+    parent.utils.showError(e.message, e);
+    // Also log error in console to help debug playgrounds
+    console.error(e);
+}
+
 /**
  * Compile the script in the editor, and run the preview in the canvas
  */
@@ -172,12 +178,11 @@ compileAndRun = function(parent, fpsLabel) {
                     }
                 }
             }
+        }).catch(e => {
+            handleException(parent, e);
         });
-
     } catch (e) {
-        parent.utils.showError(e.message, e);
-        // Also log error in console to help debug playgrounds
-        console.error(e);
+        handleException(parent, e);
     }
 };
 

+ 1 - 2
Playground/js/monacoCreator.js

@@ -172,8 +172,7 @@ class MonacoCreator {
                     var diagnostic = diagset[0];
                     var position = model.getPositionAt(diagnostic.start);
                     
-                    parent.utils.showError(`Line ${position.lineNumber}:${position.column} - ${diagnostic.messageText}`);
-                    return;
+                    throw new Error(`Line ${position.lineNumber}:${position.column} - ${diagnostic.messageText}`);
                 }
             });