-
Notifications
You must be signed in to change notification settings - Fork 92
add strongErrorHandler configuration #296
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need to change the implementation to use the new strong-error-handler module under the hood, the method names (API) can stay the same, no need to change that. |
||
| 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; | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 }}); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ideally, we should preserve backwards compatibility in the sense that it is still possible to configure the error handler via Note that the fact that we use strong-error-handler under the hood is just an implementation detail that API consumers should not need to know about. |
||
| 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) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ditto, this line should not need to be changed, the old API should continue to work in the new version. |
||
| 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; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ditto, this line should not need to be changed, the old API should continue to work in the new version. If you prefer, then we can support both settings However, while you are making this change, please change the default value of |
||
| 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(); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this change needed? I don't mind much, I just want to ensure we fully understand why we are making it. |
||
| }); | ||
| }); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the purpose of this API rename? Why can't we keep existing
errorHandlername?