1
0
Fork 0
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:
Jeremy Ashkenas 2010-12-05 15:40:49 -05:00
parent 06647bdd0a
commit 77e13e459b
2 changed files with 9 additions and 2 deletions

View file

@ -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) {

View file

@ -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> '