Repository navigation
feat: Add location() to WebError
#39767
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
Changes from 1 commit
0a0ea5f
d3492bf
982e016
94020c5
4d520d6
08730c8
4377f2e
b9c9afe
1b2633a
1328528
503334e
cbe6795
7cfd20a
9ea4eaa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -158,6 +158,22 @@ export function parseErrorStack(stack: string, pathSeparator: string, showIntern | |
| return { message, stackLines, location }; | ||
| } | ||
|
|
||
| export function errorLocationFromStack(error: Error | undefined, pathSeparator: string, showInternalStackFrames: boolean = false): { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This code works for Node.js (V8), it does not work for errors in WebKit / Firefox.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should plumb the location all the way from the browser-specific protocol event to here. It should be already available in the protcol.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Chris (@cpAdm) web error originates from the web page. That web page runs in the browser, it can be Firefox or WebKit. You can't parse Firefox error text in Node and assume it is coming from V8 - stack frame format is different.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Alright, thanks for the feedback! The error is now plumbed all the way from the browsers. I did need to change the Firefox protocol, so if I understand correctly, this still needs a revision update? But I think that needs to be done via the GitHub workflow? |
||
| url: string, | ||
| lineNumber: number, | ||
| columnNumber: number | ||
| } { | ||
| const stack = error?.stack || ''; | ||
| const frame = parseErrorStack(stack, pathSeparator, showInternalStackFrames).location; | ||
| if (!frame) | ||
| return { url: '', lineNumber: 0, columnNumber: 0 }; | ||
| return { | ||
| url: frame.file, | ||
| lineNumber: Math.max(frame.line - 1, 0), | ||
| columnNumber: Math.max(frame.column - 1, 0), | ||
| }; | ||
| } | ||
|
|
||
| function belongsToNodeModules(file: string, pathSeparator: string) { | ||
| return file.includes(`${pathSeparator}node_modules${pathSeparator}`); | ||
| } | ||
|
|
||

Uh oh!
There was an error while loading. Please reload this page.