NodeJS and CoffeeScript (coffee executable code) not behaving the same?

I have a simple test.coffee that compiles in test.js

Testing.

process.on 'uncaughtException', (er) ->
  console.log 'Unhandled exception'
  console.log 'Unhandled exception'
  console.log 'Unhandled exception'
  console.log 'Unhandled exception'
  console.log 'Unhandled exception'
  console.log 'Unhandled exception'
  console.log 'Unhandled exception'
  console.log 'Unhandled exception'
  return

throw new Error("aAH")

And the produced test.js

(function() {
  process.on('uncaughtException', function(er) {
    console.log('Unhandled exception');
    console.log('Unhandled exception');
    console.log('Unhandled exception');
    console.log('Unhandled exception');
    console.log('Unhandled exception');
    console.log('Unhandled exception');
    console.log('Unhandled exception');
    console.log('Unhandled exception');
  });
  throw new Error("aAH");
}).call(this);

From the command line or from vim via (! Node% and! Coffee%), etc. the outputs are surprisingly different.

node test.js behaves correctly and outputs to the console several excluded exception lines and exits. A call through "coffee test.coffee" returns to the default behavior for printing a stack trace and exiting. This example is obviously not my complete application, but, making a larger application, I could not get an unhandled exception to work when running my ExpressJS application through coffee boot.cofee, what am I doing wrong? This is the latest version of Node 0.4.8 and the latest version of Cofee 1.1.1 on Mac OS X 10.6.x

+3
1

CoffeeScript coffee, JS, Node. , CoffeeScript

mainModule._compile code, mainModule.filename

(. coffee-script.coffee), mainModule require.main.

Error: aAH
    at Object. (.:12:9)
    at Object. (.:13:4)
    at Module._compile (module.js:404:26)
    ...

, , , process. -

  try
    ...
    else if o.run         then CoffeeScript.run t.input, t.options
    ...
  catch err
    ...

command.coffee.

The CoffeeScript "" Node.js coffee foo.coffee, CoffeeScript JS. , , , Cakefile, , , .

+4

All Articles