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

Print error stack when handed an error #46

Closed
SLM-Linus opened this issue Apr 12, 2013 · 7 comments
Closed

Print error stack when handed an error #46

SLM-Linus opened this issue Apr 12, 2013 · 7 comments

Comments

@SLM-Linus
Copy link

Feature request: When calling debug with an err as the first and only parameter, print a stack trace from it.

I would be happy to provide PR if you think this is a good idea.

@ForbesLindesay
Copy link

That's not normally something you'd want to turn on and off?

@tj
Copy link
Contributor

tj commented Apr 12, 2013

hmm -1 from me, I think errors should always be to stderr

@ForbesLindesay
Copy link

I'm inclined to say:

  1. Libraries should never log errors, under any circumstances. They can log other debugging info, but errors should be thrown (or passed to callbacks)
  2. Applications should never hide errors, under any circumstances. If there's an unhandled error in an application, it should always get logged to stderr, and has nothing to do with debugging settings.

@tj
Copy link
Contributor

tj commented Apr 12, 2013

yeah in libs they should be emitted, but in your application etc you should delegate to something central for logging and output to stderr. Through the integration of whatever library into your application they should always reach there anyway so I dont think adding a bunch of if (err) debug(err) calls would help much

@SLM-Linus
Copy link
Author

Hmm, I totally agree with @ForbesLindesay's two points. It slipped my mind that debug isn't always enabled, I just wanted a way to print an error and see which part of my app it came from.

I also think that there might be times when you want to print it under debug circumstances thought. I'm working on a small lib to easily build api servers and clients. On the server side you register all your functions which all can take a callback (which will be executed on the client). In the case of an error, you send it in as the first parameter of the callback. The error then gets serialized and sent over an socket to the client.

When debugging this it's very nice to be able to log the Error object before sending it away to the client and forgetting about it.

In this case it would be really nice to have this feature.

@tj
Copy link
Contributor

tj commented Apr 16, 2013

fair enough it'll be a tiny patch anyway

@tj tj closed this as completed in 97a362f Apr 16, 2013
@SLM-Linus
Copy link
Author

Super, thanks!

jkroso pushed a commit to jkroso/debug that referenced this issue Apr 23, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants