airbrake.expressHandler(),错误函数不存在

时间:2012-08-24 01:20:19

标签: node.js express airbrake

我按照

的文件进行操作

https://github.com/felixge/node-airbrake

但是当我尝试时,我得到了

app.error(airbrake.expressHandler());
                 ^
TypeError: Object #<Airbrake> has no method 'expressHandler'

我的代码如下:

// dependencies
var express = require('express')
  , http = require('http')
  , logger = require('./app/lib/logger')
  , airbrake = require('airbrake').createClient('HIDDEN');

var app = express();
var env = app.settings.env;

// controllers
var InvoiceController = require('./app/controllers/invoice_controller')
  , IndexController = require('./app/controllers/index_controller')
  , PaymentController = require('./app/controllers/payment_controller')
  , AccountController = require('./app/controllers/account_controller')
  ;

// configurations and middleware stack
app.configure(function(){
  app.set('port', process.env.PORT || 3000);
  app.set('views', __dirname + '/app/views');
  app.set('view engine', 'jade');
  app.use(express.favicon());
  app.use(express.logger('dev'));
  app.use(express.bodyParser());
  app.use(express.methodOverride());
  app.use(app.router);
  app.use(express.static(__dirname + '/public'));
});

if (env === 'production' || env === 'staging' || env === 'qa') {
  app.error(airbrake.expressHandler());
} else {
  app.error(airbrake.expressHandler());
  //app.use(express.errorHandler());
}

throw new Error("testing express handler");

1 个答案:

答案 0 :(得分:2)

看起来在最后一个正式版本之后添加了特定的处理程序,并且还没有在npm存储库中:尝试从github安装最新的代码。