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

Getting at the raw trace #4

Open
jdarling opened this issue Sep 26, 2012 · 1 comment
Open

Getting at the raw trace #4

jdarling opened this issue Sep 26, 2012 · 1 comment

Comments

@jdarling
Copy link

Is there an easy way to get to the raw stack trace with longjohn? I have a generic exception handler that when called performs a new Error() to get to the trace. It would be nice if it didn't report itself in the results. Also as I'm recording these to a MongoDB I would rather write the JSONified trace than the stringified trace.

It would be even better if longjohn had some type of currentStack instead of having to do a new Error every time you need the trace details.

Even a starting point on what to modify/change would be great. I'd gladly do the pull request.

Thanks,

  • Jeremy
@mattinsler
Copy link
Owner

Hey Jeremy,

Sorry for being so behind on this!

This is an unfortunate suggestion, but try using https://github.com/felixge/node-stack-trace in order to parse the stack trace for now. I was trying to figure out a way to expose both the raw trace and the stringified trace through the same error object but have yet to figure out a good way to do this. The basic issue is that adding a property to the error object that gets returned out seemed to not be possible in the way that I did things. In essence, the prepareStackTrace method can only be called once for any error. You could take a look in there and see if you can get the raw stack attached to the error that gets returned out.

Also, if you'd like something like currentStack, you could use visionmedia's https://github.com/visionmedia/callsite to get a stacktrace. He had another lib that does exactly what you want based on callsite, but I forget what it is now.

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