Skip to content

Instantly share code, notes, and snippets.

@rakeshpai
Created February 20, 2013 12:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rakeshpai/4995193 to your computer and use it in GitHub Desktop.
Save rakeshpai/4995193 to your computer and use it in GitHub Desktop.
Opera .stack / .stacktrace madness
<!doctype html>
<title>Stackgen</title>
<script src="stackgen.js"></script>
<script>
try {
stackgen();
} catch(e) {
ex = e;
throw e;
}
</script>
function stackgen() {
newFrame();
}
function newFrame() {
badCall();
}
@rakeshpai
Copy link
Author

Following all done in Opera/11.6.

When accessing ex.stacktrace for the first time, I sometimes get the following (reload if you don't):

"

Error thrown at line 6, column 1 in http://localhost:8080/:
    throw e;

Error initially occurred at line 6, column 1 in newFrame() in http://localhost:8080/stackgen.js:
    badCall();
called from line 2, column 1 in stackgen() in http://localhost:8080/stackgen.js:
    newFrame();
called from line 3, column 1 in http://localhost:8080/:
    stackgen();"

(Yes, it has the superflous newlines)

Accessing the .stacktrace property multiple times consistently gives the same result.

Now, access ex.stack. You'll get something like this:

"newFrame([arguments not available])@http://localhost:8080/stackgen.js:6
stackgen([arguments not available])@http://localhost:8080/stackgen.js:2
@http://localhost:8080/:3"

All fine. Now, access ex.stacktrace again. I get this:

"Error thrown at line 6, column 1 in newFrame() in http://localhost:8080/stackgen.js:
    badCall();
called from line 2, column 1 in stackgen() in http://localhost:8080/stackgen.js:
    newFrame();
called from line 3, column 1 in http://localhost:8080/:
    stackgen();"

I haven't changed anything in ex. Why is .stacktrace different before and after accessing .stack?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment