Skip to content

Commit f3c0860

Browse files
authored
fix: Handle compiler crash where there is no stack trace (AssemblyScript#2064)
1 parent 63c1e85 commit f3c0860

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

cli/asc.js

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1478,12 +1478,21 @@ function crash(stage, e) {
14781478
EOL,
14791479
BAR, "Whoops, the AssemblyScript compiler has crashed during ", stage, " :-(", EOL,
14801480
BAR, EOL,
1481-
BAR, "Here is a stack trace that may or may not be useful:", EOL,
1482-
BAR, EOL,
1483-
e.stack.replace(/^/mg, BAR), EOL,
1484-
BAR, EOL,
1485-
BAR, "If it refers to the dist files, try to 'npm install source-map-support' and", EOL,
1486-
BAR, "run again, which should then show the actual code location in the sources.", EOL,
1481+
(typeof e.stack === "string"
1482+
? [
1483+
BAR, "Here is the stack trace hinting at the problem, perhaps it's useful?", EOL,
1484+
BAR, EOL,
1485+
e.stack.replace(/^/mg, BAR), EOL,
1486+
BAR, EOL,
1487+
BAR, "If it refers to the dist files, try to 'npm install source-map-support' and", EOL,
1488+
BAR, "run again, which should then show the actual code location in the sources.", EOL,
1489+
]
1490+
: [
1491+
BAR, "There is no stack trace. Perhaps a Binaryen exception above / in console?", EOL,
1492+
BAR, EOL,
1493+
BAR, "> " + e.stack, EOL
1494+
]
1495+
).join(""),
14871496
BAR, EOL,
14881497
BAR, "If you see where the error is, feel free to send us a pull request. If not,", EOL,
14891498
BAR, "please let us know: https://github.com/AssemblyScript/assemblyscript/issues", EOL,

0 commit comments

Comments
 (0)