-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[SEMVER-MAJOR] Remove loopback#errorHandler
middleware
#2411
Conversation
@loay Could you please link this pull request with the GH issue where we discussed this change? I think it will be better to completely remove |
loopback#errorHandler
middleware
@loay please add an entry into 3.0-RELEASE-NOTES.md, don't forget to include a link to this pull request - see other entries for inspiration. |
@slnode test please |
In
as it was set to
and it did run fine locally, as @bajtos PTAL |
@@ -127,3 +127,16 @@ removed properties together with the middleware module name to use instead: | |||
We have also removed `loopback.mime`, which was always set to `undefined`. | |||
|
|||
See [loopback#2349](https://github.com/strongloop/loopback/pull/2394). | |||
|
|||
## remove `loopback.errorhandler` |
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.
Remove loopback#errorhandler
We have removed loopback#errorhandler
middleware, users should use strong-error-handler
directly.
// server/middleware.json
{
// ...
"final:after": {
"strong-error-handler": {}
}
}
// server/middleware.development.json
{
"final:after": {
"strong-error-handler": {
"params": {
"debug": true
}
}
}
See also strong-error-handler's options and the related code change.
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.
^^^ click on the "edit" icon of the comment above, copy the markdown source and use it to replace the content of the new section you are adding.
@loay reviewed, PTAL |
@bajtos PTAL. Thanks |
@@ -1652,7 +1652,7 @@ describe('relations - integration', function() { | |||
expect(res.body).to.be.an('object'); | |||
expect(res.body.error).to.be.an('object'); | |||
expect(res.body.error.name).to.equal('Error'); | |||
expect(res.body.error.statusCode).to.equal(500); | |||
expect(res.statusCode).to.equal(500); |
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.
Could you please check with @davidcheung whether this change is needed. I am surprised that body.error.statusCode
is not available.
The code change LGTM, please make sure Travis CI builds and Jenkins builds (possibly excluding unstable dependants) are passing before landing. |
@loay also squash the commits before landing :) |
} | ||
} | ||
module.exports = function(options) { | ||
throw new Error ('loopback.errorHandler is no longer available.' + |
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.
We don't put space between function name and argument list, i.e. Error(
Could you please add a rule to our eslint config to catch this?
I'n using strongErrorHandler with loopback 3.0.0-alpha.1. That's really a pain. It annoyed me with sort of message e.g: "Unhandled error for request GET /MyModel/action". How can I turn it off? I also disabled log & debug in both "final:after": {
"strong-error-handler": {
"params": {
"debug": true,
"log": true
}
}
} Btw, I use loggy to store error message. For loopback 2.x, I send error log in config.local.js module.exports = {
restApiRoot: '/api' + (version > 0 ? '/v' + version : ''),
host: process.env.HOST || 'localhost',
port: process.env.PORT || 3000,
remoting: {
errorHandler: {
handler: function(err, req, res, next) {
log.l('api-error', {
method: req.method,
originalUrl: req.originalUrl,
statusCode: res.statusCode,
stack: err.stack,
});
next(err);
},
},
},
}; But err.stack is not available in 3.x. I have to change it to How can I do this officially? |
Hi @rickyngk ! I have encountered the same issue. The problem is the RestAdapter.errorHandler in the rest-adapter.js calling the new strongErrorHandler with ITS OWN option object, not the one the documentation suggest in the server/middleware.json. To overcome and apply your desired params use the following in the server/config.json:
@bajtos this should be mentioned in the migrate doc, because the full migration is not possible right now if you want to use options when using the strong error handler for the REST adapter. T. |
@ttothAISS thanks for pointing it out, the migration guide for REST adapter error-handler should be this instead, will follow up and fix |
connect to #2338