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

provide a way to synchronously parse an error #23

Closed
elesueur opened this issue Nov 11, 2015 · 1 comment
Closed

provide a way to synchronously parse an error #23

elesueur opened this issue Nov 11, 2015 · 1 comment

Comments

@elesueur
Copy link

I have been using the 0.6 versions of stacktrace-js, but I was getting a warning from chrome about synchronous requests from the main thread being deprecated, so I am investigating updating to the new version.

The case I have is I want to augment a logging module to prefix the file:line:column to each log message, but because of the asynchronous nature of the interface that stacktrace-js exposes, it doesn't seem possible to do it.

I have hacked at the fromError method to remove the asynchronous interface and just return the stack frame array, and it seems to work, but I am no longer calling into the GPS module. I guess it's the GPS module that needs to download the source map.

It would be good to also provide an synchronous interface, e.g.:

70 /**
71 * Given an error object, parse it synchronously without source mapping.
72 * @param error Error object
73 * @param opts Object for options
74 * @return Array[StackFrame]
75 */
76 getStackFrames: function StackTrack$$getStackFrames(error, opts) {
77 opts = _merge(_options, opts);
78
79 var stackframes = ErrorStackParser.parse(error);
80
81 if (typeof opts.filter === 'function') {
82 stackframes = stackframes.filter(opts.filter);
83 }
84
85 return stackframes;
86 },

Sorry, I meant to file this issue against stacktrace-js, not stacktrace-gps.

@eriwen
Copy link
Member

eriwen commented Nov 12, 2015

@elesueur If all you want to do is parse an Error (and not enhance it with source maps, etc.) then error-stack-parser is for you. It does exactly what you describe!

Please let us know if I misunderstood your request or error-stack-parser doesn't do everything you want.

@eriwen eriwen closed this as completed Nov 22, 2015
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

2 participants