Javascript 设置全局PhantomJS错误处理程序

Javascript 设置全局PhantomJS错误处理程序,javascript,error-handling,phantomjs,Javascript,Error Handling,Phantomjs,以下代码摘自phantomjs食谱。我想会收到以下消息“[PHANTOMJS ERROR]ERROR:Gremlins在午夜后进食。” 但它不起作用;它在不记录任何内容的情况下退出: 代码如下: phantom.onError = function(message, trace) { console.error('[PHANTOMJS ERROR] ' + message); trace.forEach(function(t) { console.error(' >>

以下代码摘自phantomjs食谱。我想会收到以下消息“
[PHANTOMJS ERROR]ERROR:Gremlins在午夜后进食。
” 但它不起作用;它在不记录任何内容的情况下退出:

代码如下:

phantom.onError = function(message, trace) {
  console.error('[PHANTOMJS ERROR] ' + message);
  trace.forEach(function(t) {
    console.error(' >> [' + t.line + '] ' +
      (t.function ? '[' + t.function + '] ' : '') +
      t.file || t.sourceURL);
  });
  phantom.exit(1);
};

function doSomeErrorProneStuff() {
  throw new Error('Gremlins fed after midnight.');
}

doSomeErrorProneStuff();
console.log('Exiting cleanly.');
phantom.exit(0);

有什么东西已经被弃用了吗?

这是PhantomJS 2.0.0中的一个已知错误。我正在寻找复制品。这是PhantomJS 2.0.0中的一个已知错误。我正在找复制品。