Skip to content

Instantly share code, notes, and snippets.

@Tigraine
Created June 26, 2014 09:40
Show Gist options
  • Save Tigraine/3092ec6f6c1b929d3d2f to your computer and use it in GitHub Desktop.
Save Tigraine/3092ec6f6c1b929d3d2f to your computer and use it in GitHub Desktop.
// If you are faced with a stupid library swallowing callback exceptions this
// function will still report the exception details to you.
function exposeException(fn) {
return function () {
try {
return fn.apply(this, arguments);
} catch (e) {
console.log("Exception occured", e);
throw e;
}
}
}
//usage:
$('button').onclick(exposeException(function () {
throw "Oops..";
}));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment