Uh oh!
There was an error while loading. Please reload this page.
[SEMVER-MAJOR] Remove loopback#errorHandler middleware - #2411
Conversation
bajtos
commented
Jun 8, 2016
@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 middlewarebajtos
commented
Jun 8, 2016
@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. |
loay
commented
Jun 10, 2016
@slnode test please |
In
as it was set to
and it did run fine locally, as @bajtos PTAL |
| See [loopback#2349](https://github.com/strongloop/loopback/pull/2394). | ||
| ## remove `loopback.errorhandler` |
There was a problem hiding this comment.
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.
^^^ 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.
bajtos
commented
Jun 10, 2016
@loay reviewed, PTAL |
loay
commented
Jun 10, 2016
@bajtos PTAL. Thanks |
| 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.
Could you please check with @davidcheung whether this change is needed. I am surprised that body.error.statusCode is not available.
bajtos
commented
Jun 13, 2016
The code change LGTM, please make sure Travis CI builds and Jenkins builds (possibly excluding unstable dependants) are passing before landing. |
bajtos
commented
Jun 13, 2016
@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.
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?
rickyngk
commented
Jul 26, 2016
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? |
ttothAISS
commented
Oct 25, 2016
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. |
davidcheung
commented
Oct 25, 2016
@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