diff --git a/cli/asc.js b/cli/asc.js index f1dfc427f3..6bccf12a4d 100644 --- a/cli/asc.js +++ b/cli/asc.js @@ -1478,12 +1478,21 @@ function crash(stage, e) { EOL, BAR, "Whoops, the AssemblyScript compiler has crashed during ", stage, " :-(", EOL, BAR, EOL, - BAR, "Here is a stack trace that may or may not be useful:", EOL, - BAR, EOL, - e.stack.replace(/^/mg, BAR), EOL, - BAR, EOL, - BAR, "If it refers to the dist files, try to 'npm install source-map-support' and", EOL, - BAR, "run again, which should then show the actual code location in the sources.", EOL, + (typeof e.stack === "string" + ? [ + BAR, "Here is the stack trace hinting at the problem, perhaps it's useful?", EOL, + BAR, EOL, + e.stack.replace(/^/mg, BAR), EOL, + BAR, EOL, + BAR, "If it refers to the dist files, try to 'npm install source-map-support' and", EOL, + BAR, "run again, which should then show the actual code location in the sources.", EOL, + ] + : [ + BAR, "There is no stack trace. Perhaps a Binaryen exception above / in console?", EOL, + BAR, EOL, + BAR, "> " + e.stack, EOL + ] + ).join(""), BAR, EOL, BAR, "If you see where the error is, feel free to send us a pull request. If not,", EOL, BAR, "please let us know: https://github.com/AssemblyScript/assemblyscript/issues", EOL,