Created
April 3, 2011 05:24
-
-
Save kbjr/900217 to your computer and use it in GitHub Desktop.
YourBrowserFailsError
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
// For those cases when there just isn't any other explanation... | |
if (typeof window.YourBrowserFailsError === 'undefined') { | |
window.YourBrowserFailsError = function(msg) { | |
// Make sure it is called with "new" | |
if (! this instanceof YourBrowserFailsError) { | |
return new YourBrowserFailsError(msg); | |
} | |
// Get an actual error object for the stack | |
var err = (function() { | |
var err; | |
try { (0)(); } catch (e) { err = e; } | |
return err; | |
}()); | |
// Set the error message | |
this.name = 'YourBrowserFailsError'; | |
this.message = msg; | |
this.stack = err.stack || 'Could not get a stack. MORE FAILS!!'; | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment