You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Instructions for customising REST errorHandler #688
We need to document instructions for setting a custom errorHandler via server/config.local.js.
strongloop/strong-remoting#114 implements support for errorHandler option, #337 will hopefully modify loopback.rest to pass app.get('remoting').rest options to the REST handler.
I believe this should work with the current loopback version:
// server/config.local.jsonmodule.exports={remoting: {errorHandler: {handler: function(err,req,res,next){// custom error handling logic// call `next()` to fall back to the default error handler}}}};
On a related note, error stack traces can be disabled via server/config.json like this:
just for the sake of understanding, you have two error handlers, one referenced in middleware.json and another one in strong-remoting. when does the error handler defined in middleware.json kick in? I tried defining a custom one but it never kicked in. To test, I created a custom API route that explicitly returns an error on callback cb(err). I also used a mix of throw err and 1/0 to see if I could trigger the custom error middleware but no luck there. ps I defined the error handler with 4 arguments as express expects.
@simoami You should ask your question on the Google Group. No one will notice it here in a closed GH issue.
PS. If I knew the answer, I would tell you, but I don't :-)
Activity
bajtos commentedon Nov 5, 2014
I believe this should work with the current loopback version:
On a related note, error stack traces can be disabled via
server/config.jsonlike this:{ "remoting": { "errorHandler": { "disableStackTrace": true } } }26 remaining items
crandmck commentedon Jan 20, 2015
Added http://docs.strongloop.com/display/LB/Environment-specific+configuration#Environment-specificconfiguration-CustomizingRESTerrorhandling.
crandmck commentedon Jan 20, 2015
@bajtos Please review and close if it looks OK.
bajtos commentedon Jan 21, 2015
LGTM.
jrschumacher commentedon Mar 8, 2015
There should be a link to the customizing REST error handling on http://docs.strongloop.com/display/public/LB/Defining+middleware
crandmck commentedon Mar 9, 2015
Added a link to http://docs.strongloop.com/display/LB/Defining+middleware#Definingmiddleware-Error-handlingmiddleware.
simoami commentedon Oct 16, 2015
just for the sake of understanding, you have two error handlers, one referenced in middleware.json and another one in strong-remoting. when does the error handler defined in middleware.json kick in? I tried defining a custom one but it never kicked in. To test, I created a custom API route that explicitly returns an error on callback
cb(err). I also used a mix ofthrow errand1/0to see if I could trigger the custom error middleware but no luck there. ps I defined the error handler with 4 arguments as express expects.crandmck commentedon Oct 16, 2015
@simoami You should ask your question on the Google Group. No one will notice it here in a closed GH issue.
PS. If I knew the answer, I would tell you, but I don't :-)