Create a gist now

Instantly share code, notes, and snippets.

try/catch example
function thisMightFail() {
//...
if(badThingsHappened) {
throw new Error(...);
}
return theGoodResult;
}
function recoverFromFailure(e) {
//...
return recoveryValue;
}
function getTheResult() {
var result;
try {
result = thisMightFail();
} catch(e) {
result = recoverFromFailure(e);
}
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment