mirror of
https://github.com/jashkenas/coffeescript.git
synced 2022-11-09 12:23:24 -05:00
Fixing the repl so that errors print properly, and async exceptions are logged instead of killing the session.
This commit is contained in:
parent
06647bdd0a
commit
77e13e459b
2 changed files with 9 additions and 2 deletions
|
@ -21,10 +21,13 @@
|
|||
console.log(val);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(err.stack || err.toString());
|
||||
stdio.write(err.stack || err.toString());
|
||||
}
|
||||
return repl.prompt();
|
||||
};
|
||||
process.on('uncaughtException', function(err) {
|
||||
return stdio.write(err.stack || err.toString());
|
||||
});
|
||||
repl = readline.createInterface(stdio);
|
||||
repl.setPrompt('coffee> ');
|
||||
stdio.on('data', function(buffer) {
|
||||
|
|
|
@ -23,9 +23,13 @@ run = (buffer) ->
|
|||
val = CoffeeScript.eval buffer.toString(), bare: on, globals: on, fileName: 'repl'
|
||||
console.log val if val isnt undefined
|
||||
catch err
|
||||
console.error err.stack or err.toString()
|
||||
stdio.write err.stack or err.toString()
|
||||
repl.prompt()
|
||||
|
||||
# Make sure that uncaught exceptions don't kill the REPL.
|
||||
process.on 'uncaughtException', (err) ->
|
||||
stdio.write err.stack or err.toString()
|
||||
|
||||
# Create the REPL by listening to **stdin**.
|
||||
repl = readline.createInterface stdio
|
||||
repl.setPrompt 'coffee> '
|
||||
|
|
Loading…
Add table
Reference in a new issue