1
0
Fork 0
mirror of https://github.com/jashkenas/coffeescript.git synced 2022-11-09 12:23:24 -05:00

Fix CLI crash when null is thrown

Before:

```
$ ./bin/coffee -e 'throw null'
/src/coffee-script/lib/coffee-script/command.js:251
      message = err.stack || ("" + err);
                   ^

TypeError: Cannot read property 'stack' of null
  at compileScript ...
```

After:

```
$ ./bin/coffee -e 'throw null'
null
```

Supersedes and closes #4135.
This commit is contained in:
Simon Lydell 2016-09-14 21:33:36 +02:00
parent ec9c4d8594
commit 0e0e8f87e1
2 changed files with 2 additions and 2 deletions

View file

@ -248,7 +248,7 @@
if (CoffeeScript.listeners('failure').length) {
return;
}
message = err.stack || ("" + err);
message = (err != null ? err.stack : void 0) || ("" + err);
if (o.watch) {
return printLine(message + '\x07');
} else {

View file

@ -198,7 +198,7 @@ compileScript = (file, input, base = null) ->
catch err
CoffeeScript.emit 'failure', err, task
return if CoffeeScript.listeners('failure').length
message = err.stack or "#{err}"
message = err?.stack or "#{err}"
if o.watch
printLine message + '\x07'
else