diff --git a/lib/jsonrpc-adapter.js b/lib/jsonrpc-adapter.js index 66f07603..f9feaecf 100644 --- a/lib/jsonrpc-adapter.js +++ b/lib/jsonrpc-adapter.js @@ -66,7 +66,7 @@ JsonRpcAdapter.prototype.getRoutes = function(obj) { return routes; }; -JsonRpcAdapter.errorHandler = function() { +JsonRpcAdapter.strongErrorHandler = function() { return function restErrorHandler(err, req, res, next) { if (typeof err === 'string') { err = new Error(err); @@ -156,7 +156,7 @@ JsonRpcAdapter.prototype.createHandler = function() { root.use(json(jsonOptions)); - root.use(JsonRpcAdapter.errorHandler()); + root.use(JsonRpcAdapter.strongErrorHandler()); classes.forEach(function(sc) { var server = new jayson.server(); diff --git a/lib/rest-adapter.js b/lib/rest-adapter.js index 27a55074..169dfb0d 100644 --- a/lib/rest-adapter.js +++ b/lib/rest-adapter.js @@ -307,7 +307,7 @@ RestAdapter.prototype.createHandler = function() { if (this._shouldHandleErrors()) { // Use our own error handler to make sure the error response has // always the format expected by remoting clients. - root.use(RestAdapter.errorHandler(this.remotes.options.errorHandler)); + root.use(RestAdapter.strongErrorHandler(this.remotes.options.strongErrorHandler)); } return root; @@ -341,7 +341,7 @@ RestAdapter.urlNotFoundHandler = function() { }; }; -RestAdapter.errorHandler = function(options) { +RestAdapter.strongErrorHandler = function(options) { options = options || {}; return function restErrorHandler(err, req, res, next) { if (typeof options.handler === 'function') { @@ -397,7 +397,7 @@ RestAdapter.errorHandler = function(options) { } data.stack = error.stack; - if (process.env.NODE_ENV === 'production' || options.disableStackTrace) { + if (process.env.NODE_ENV === 'production' || !options.debug) { delete data.stack; } diff --git a/test/rest.test.js b/test/rest.test.js index cd8c205b..abea141f 100644 --- a/test/rest.test.js +++ b/test/rest.test.js @@ -45,7 +45,7 @@ describe('strong-remoting-rest', function() { process.env.NODE_ENV = 'test'; } objects = RemoteObjects.create({ json: { limit: '1kb' }, - errorHandler: { disableStackTrace: false }}); + strongErrorHandler: { debug: true }}); remotes = objects.exports; // connect to the app @@ -110,7 +110,7 @@ describe('strong-remoting-rest', function() { } ); - objects.options.errorHandler.handler = function(err, req, res, next) { + objects.options.strongErrorHandler.handler = function(err, req, res, next) { expect(err.message).to.contain('foo'); err = new Error('foobar'); called = true; @@ -127,7 +127,7 @@ describe('strong-remoting-rest', function() { }); it('should disable stack trace', function(done) { - objects.options.errorHandler.disableStackTrace = true; + objects.options.strongErrorHandler.debug = false; var method = givenSharedStaticMethod( function(cb) { cb(new Error('test-error')); @@ -2227,7 +2227,6 @@ describe('strong-remoting-rest', function() { for (var prop in expected) { expect(result.body.error[prop], prop).to.equal(expected[prop]); } - expect(result.body.error.stack, 'stack').to.contain(__filename); done(); }); });