Created
June 26, 2014 09:40
-
-
Save Tigraine/3092ec6f6c1b929d3d2f to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// 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