Description
In previous versions of parse-server,
(<2.3), I was able to handle generic errors in express.js error handler, but that capability has been removed (~ one year ago) by this PR 145a1fe.
It basically replaces next(err)
by log.error(err.message, err)
assuming that calling the default error handler is useless. But it missed an important point... The logger don't have the request, but the express handler does. It's extremely important in my case to track which request path and parameters caused the error.
Since then I'm using patched forks of parse server that calls next(err)
besides the logger.
I strongly believe it's the right way to go.
Steps to reproduce
- Implement an express error handler:
app.use(function(err, req, res, next) {
console.error(err.message || err, 'path:', req.path);
// Do whatever you want to get the contect of the error
})
- Run the server and generate an error by getting an invalid object, for example:
curl --request GET \
--url http://localhost:1337/parse/classes/Whatever/blablabla \
--header 'x-parse-application-id: <appid>' \
--header 'x-parse-master-key: <masterkey if needed>'
Expected Results
The error handler is called and the error is logged in the console with the path.
Actual Outcome
Nothing happens
Environment Setup
-
Server
- parse-server version (Be specific! Don't say 'latest'.) : 2.7.4
- Operating System: MacOS and heroku dyno
- Hardware: Heroku Dyno X2
- Localhost or remote server? (AWS, Heroku, Azure, Digital Ocean, etc): Localhost and Heroku
-
Database
- MongoDB version: 3.2.17 (WiredTiger)
- Localhost or remote server? (AWS, mLab, ObjectRocket, Digital Ocean, etc): mLab
More context on this: #2841