-
-
Notifications
You must be signed in to change notification settings - Fork 24
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
Cleaner stack traces #64
Comments
Could you provide an example of some code containing a type error, the current stack trace, and the stack trace we'd see instead were we to use stack-utils? |
Sure! Take the following code with improperly uses Sanctuary's maybe: const { Just } = require('sanctuary')
Just(4).chain(x => x) It results in the following error:
stack-utils is pretty dumb, it just filters out some lines of the stack trace based on patterns you provide yourself. Suppose we filter out everything with
Which is arguably is what the end user of the Sanctuary library is really interested in. For this to work not just with Sanctuary, but any library using sanctuary-def, the consumer of sanctuary-def should be able to provide the patterns sanctuary-def uses to clean up the stack traces. |
Thanks for the instructive example. I agree that the filtered stack trace is much nicer. :)
Is that so? In the above example, at least, one could drop lines up to and including the last occurrence of My concern is that this approach makes assumptions about file locations. In the browser it's common to concatenate source files, precluding us from using file locations to determine where user code ends and sanctuary-def code begins. |
You're right, that could make things easier.
stack-utils is pulled out of the test runner |
Another strategy would be to immediately create and store a stack the moment a |
|
Cool! I'll try to find some time next week to try it out. |
Excellent. :) |
I was wondering what people think of using a lib like stack-utils to clean up the stack trace to ensure the first line of the stack corresponds to the function call that causes the TypeError.
The text was updated successfully, but these errors were encountered: