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

Chrome stack not always consistent with others #1

Closed
eriwen opened this issue Jan 26, 2010 · 2 comments
Closed

Chrome stack not always consistent with others #1

eriwen opened this issue Jan 26, 2010 · 2 comments

Comments

@eriwen
Copy link
Member

eriwen commented Jan 26, 2010

Chrome seems to report some functions as anonymous when they are not. For instance:

function f2() {
    try {(0)();} catch(e) { 
        alert(e.stack);
    }
}
f2();

reports a stack containing only an anonymous function.

@iainxt
Copy link

iainxt commented Apr 6, 2010

It appears to be this code:

chrome: function(e) {
     return e.stack.replace(/^.*?\n/, '').
             replace(/^.*?\n/, '').
             replace(/^.*?\n/, '').
             replace(/^[^\(]+?[\n$]/gm, '').
             replace(/^\s+at\s+/gm, '').
             replace(/^Object.<anonymous>\s*\(/gm, '{anonymous}()@').
             split("\n");
 }

I use the following code instead

    return e.stack.replace(/^.*?\n/, ''). // Remove the first line which is the exception message
        replace(/^\s*/, '').   // Clean up the white space at the beginning of the string
        replace(/\s*\n/, '\n').   // Clean up the white space before a new line
        replace(/\s*\n/, '\n').   // Clean up the white space after a new line
        replace(/\s*$/, '').   // Clean up the white space at the end of the string
        replace(/Object.<anonymous>\s*\(/gm, '{anonymous}()@('). // re-word Object.<anonymous> as {anonymous}()@
        split('\n');

Although I don't really understand what the original code is trying to do. Its all Regular Expression voodoo to me!

@eriwen
Copy link
Member Author

eriwen commented Apr 28, 2010

I've updated the Chrome mode to match others.

This issue was closed.
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