Skip to content

Commit 856d5f8

Browse files
Eric LeeseDevtools-frontend LUCI CQ
authored andcommitted
Look for stack frames to parse without looking for Error
Previously we searched for a message to start with a word ending in "Error" to determine if it was an error and we should look for stack frames. With this change we make no assumptions about what an error is named and just look for stack frames instead. Bug: 406029201 Change-Id: I7c31c6b4cd4a9137227a99baf34626cdd51dbc16 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6563869 Commit-Queue: Eric Leese <leese@chromium.org> Auto-Submit: Eric Leese <leese@chromium.org> Reviewed-by: Philip Pfaffe <pfaffe@chromium.org>
1 parent 082b67a commit 856d5f8

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

front_end/panels/console/ErrorStackParser.test.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,13 @@ describe('ErrorStackParser', () => {
3535
assert.isNull(parseErrorStack('foobar'));
3636
});
3737

38-
it('returns null if the first word does not end in "Error"', () => {
39-
assert.isNull(parseErrorStack('CustomFoo: bar'));
38+
it('returns null if there are no stack frames', () => {
39+
assert.isNull(parseErrorStack('Error: bar'));
4040
});
4141

42-
it('accepts stacks with any "*Error" as its first word', () => {
43-
assert.isNotNull(parseErrorStack('Error: standard error'));
44-
assert.isNotNull(parseErrorStack('ReferenceError: unknown variable'));
45-
assert.isNotNull(parseErrorStack('CustomError: foobar'));
42+
it('accepts stacks if the first word of any line after the first line is "at"', () => {
43+
assert.isNotNull(parseErrorStack('!\nat foo'));
44+
assert.isNotNull(parseErrorStack('ReferenceError:\n at foo'));
4645
});
4746

4847
it('omits position information for frames it cannot parse', () => {

front_end/panels/console/ErrorStackParser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export interface ParsedErrorFrame {
3232
*/
3333
export function parseSourcePositionsFromErrorStack(
3434
runtimeModel: SDK.RuntimeModel.RuntimeModel, stack: string): ParsedErrorFrame[]|null {
35-
if (!/^[\w.]*Error\b/.test(stack)) {
35+
if (!(/\n\s*at\s/.test(stack) || stack.startsWith('SyntaxError:'))) {
3636
return null;
3737
}
3838
const debuggerModel = runtimeModel.debuggerModel();

0 commit comments

Comments
 (0)