Created
December 20, 2010 17:03
-
-
Save tautologistics/748644 to your computer and use it in GitHub Desktop.
Example of explicitly names methods for concise exception stack traces
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<script language="Javascript"> | |
function Example () {} | |
Example.prototype.NoName = function () { | |
this.foo(); | |
} | |
Example.prototype.ShortName = function ShortName () { | |
this.foo(); | |
} | |
Example.prototype.FullName = function Example$FullName () { | |
this.foo(); | |
} | |
function ExampleDupeMethods () {} | |
ExampleDupeMethods.prototype.NoName = function () { | |
Example.prototype.NoName.call(this); | |
} | |
ExampleDupeMethods.prototype.ShortName = function ShortName () { | |
Example.prototype.ShortName.call(this); | |
} | |
ExampleDupeMethods.prototype.FullName = function ExampleDupeMethods$FullName () { | |
Example.prototype.FullName.call(this); | |
} | |
var example = new Example(); | |
var exampleDupe = new ExampleDupeMethods(); | |
try { | |
example.NoName(); | |
} catch (e) { | |
console.log(e.stack); | |
} | |
try { | |
example.ShortName(); | |
} catch (e) { | |
console.log(e.stack); | |
} | |
try { | |
example.FullName(); | |
} catch (e) { | |
console.log(e.stack); | |
} | |
try { | |
exampleDupe.ShortName(); | |
} catch (e) { | |
console.log(e.stack); | |
} | |
try { | |
exampleDupe.FullName(); | |
} catch (e) { | |
console.log(e.stack); | |
} | |
/* | |
()@file:///.../example.html:7 | |
@file:///.../example.html:31 | |
ShortName()@file:///.../example.html:10 | |
@file:///.../example.html:37 | |
Example$FullName()@file:///.../example.html:13 | |
@file:///.../example.html:43 | |
ShortName()@file:///.../example.html:10 | |
ShortName()@file:///.../example.html:21 | |
@file:///.../example.html:49 | |
Example$FullName()@file:///.../example.html:13 | |
ExampleDupeMethods$FullName()@file:///.../example.html:24 | |
@file:///.../example.html:55 | |
*/ | |
</script> | |
</head> | |
<body> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment