-
Notifications
You must be signed in to change notification settings - Fork 1
Description
It would be nice if there was some automatic logging of errors when a 500 status is returned.
module.exports = {
post() {
return Promise.reject(new Error('something went wrong'))
}
}
Current behaviour:
manner returns a 500 status code, nothing is logged.
Desired behaviour:
In addition to returning a 500 status code, provide some automatic logging of the error -- the route, the parameters and body, and the error itself.
Something like
manner error (500) while responding to /foo/bar
parameters: {
bar: 'baz'
}
body: {
stuff: 'more-stuff'
}
Error: Cannot fizz the zipzap
at zipzap.fizz (/path/to/zipzap.js)
.... rest of stack trace
Motivation:
It seems from this discussion on software engineering stack exchange that's it's a good practice to be logging them. (The questions itself isn't strictly related, but the answers address exceptions and logging in general and so they seem to apply here -- especially if you consider the server backed by manner as one component in a bigger integrated system that depends on its results). It would be nice to have errors logged automatically when we return a 500 status code instead of leaving it up to the implementor of each method to log explicitly.
The alternative is to manually add .catch(error => { log(error); throw error })
at the end of each method, but that's a lot of duplication and doesn't give the same context that I'm suggesting.