Fumble节点错误对象
Fumble 是简单的节点里的错误对象。专门为 fetchr 库创建,基于 hapi.js。
示例代码:
var fumble = require('fumble'); var callAndProcess = require('./callAndProcess'); module.exports = require('api').base.service({ name: 'foo', read: function (req, resource, params, context, callback) { switch(resource) { case this.name: callAndProcess(req, params, context, callback); return; } var error = fumble.http.create(400, 'Passed in an invalid resource', { debug: [resource] }); req.error(error); req.debug(error.stack); // nice stack trace /** * logs: * { [HttpError: Bad Request] statusCode: 400, message: * 'Passed in an invalid resource', debug: [ resource ] } */ callback(error); } });
评论