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

Make res.error / res.err an Error object #156

Closed
rauchg opened this issue Nov 28, 2012 · 3 comments
Closed

Make res.error / res.err an Error object #156

rauchg opened this issue Nov 28, 2012 · 3 comments

Comments

@rauchg
Copy link
Contributor

rauchg commented Nov 28, 2012

Populated with useful debugging information:

  • type ('socket' or 'http')
  • text (body)
  • url
  • status
  • headers

Example use case in Express:

request.get('/', function(res){
  // no wrapping needed that usually drops context
  if (res.err) return next(res.err);
});

Goals:

  • ✓ Encompasses both socket and protocol (eg: 500 status) errors elegantly, but still flexible.
  • ✓ Easy next ing, console.log ing, or passing around to handlers that already interpret Error objects
  • ✓ Works with arity checks: err, res signatures would get res.err, res
@rauchg
Copy link
Contributor Author

rauchg commented Nov 28, 2012

+1

@tj
Copy link
Contributor

tj commented Nov 28, 2012

+1 I forgot they're all bools anyway so it might as well be something useful

@tj tj closed this as completed in ec98c8a Jan 3, 2013
@tj
Copy link
Contributor

tj commented Jan 3, 2013

we could add err.request = this though potentially leaking memory pretty bad

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

2 participants