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

WIP: get better frame info from prepareStackTrace #4232

Closed
wants to merge 1 commit into from

Conversation

kevinkassimo
Copy link
Contributor

@kevinkassimo kevinkassimo commented Mar 3, 2020

This is a hacked-up demo of how to leverage prepareStackTrace to get better error messages. Currently there are errors if you try throwing non-error or call eval that errors, but those are problems that could be addressed easily after validating this demo.

Example:

await Deno.open("./BOOM");

Before (deno 0.35.0, thus there are a few more frames than master):

error: Uncaught NotFound: No such file or directory (os error 2)
► $deno$/errors.ts:37:13
    at NotFound ($deno$/errors.ts:75:5)
    at constructError ($deno$/errors.ts:37:13)
    at unwrapResponse ($deno$/dispatch_json.ts:41:12)
    at sendAsync ($deno$/dispatch_json.ts:96:10)

After:

error: Uncaught NotFound: No such file or directory (os error 2)
    at unwrapResponse ($deno$/dispatch_json.ts:42:12)
    at sendAsync ($deno$/dispatch_json.ts:97:11)
    at async open ($deno$/files.ts:94:16)
    at async file:///Users/kun/Projects/Deno/test/tla.ts:1:1

);
.map((callSite): string => {
// @ts-ignore
error["__callSites"].push(callSite); // Save callsites to self
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe just assign the whole array above/below?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can definitely do that, but actually I was thinking about not saving callSite but an object populated with data we need (since currently I am actually calling a bunch of function from Rust)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with @kevinkassimo on this one.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would also consider implementing the entire prepareStackTrace function in C++.

Not 100% sure, but it might be nice to keep the part where the call sites get stored and where they get processed close together.

That is something that I can do if you don't want to btw.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@piscisaureus Yeah I think that is reasonable. I don't think I will have enough time to work on it this week (finals are coming), so yeah for sure

Copy link
Collaborator

@nayeemrmn nayeemrmn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Getting a +1 offset for column/row numbers.

deno/core/js_errors.rs

Lines 217 to 218 in 93aed08

let line_number = line_number + 1;
let column = column + 1;
adjusts for the 0-based numbers that the old API gives?

@kevinkassimo
Copy link
Contributor Author

Getting a +1 offset for column/row numbers.

deno/core/js_errors.rs

Lines 217 to 218 in 93aed08

let line_number = line_number + 1;
let column = column + 1;

adjusts for the 0-based numbers that the old API gives?

Ooops forgot to add 1, but yeah it is a small problem that could be fixed easily.

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

Successfully merging this pull request may close these issues.

3 participants