Skip to content
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

automatically log errors when returned Promises reject and 500 status is returned #39

Open
alexanderbird opened this issue Feb 9, 2018 · 0 comments

Comments

@alexanderbird
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant