Skip to content

Instantly share code, notes, and snippets.

@kbjr
Created April 3, 2011 05:24
Show Gist options
  • Save kbjr/900217 to your computer and use it in GitHub Desktop.
Save kbjr/900217 to your computer and use it in GitHub Desktop.
YourBrowserFailsError
// 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