Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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
You can’t perform that action at this time.