1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
|
function errorTry() {
try {
throw new Error('Break');
console.log('removed');
} catch {
console.log('retained');
} finally {
console.log('retained');
}
console.log('retained');
}
try {
errorTry();
} catch {}
function errorCatch() {
try {
console.log('retained');
} catch {
throw new Error('Break');
console.log('removed');
} finally {
console.log('retained');
}
console.log('retained');
}
try {
errorCatch();
} catch {}
function errorFinally() {
try {
console.log('retained');
} catch {
console.log('retained');
} finally {
throw new Error('Break');
console.log('removed');
}
console.log('removed');
}
try {
errorFinally();
} catch {}
function tryAfterError() {
console.log(hoisted1, hoisted2, hoisted3);
throw new Error();
try {
console.log('removed');
var hoisted1;
} catch {
console.log('removed');
var hoisted2;
} finally {
console.log('removed');
var hoisted3;
}
console.log('removed');
}
try {
tryAfterError();
} catch {}
function errorTryNoCatch() {
try {
throw new Error('Break');
console.log('removed');
} finally {
console.log('retained');
}
console.log('retained');
}
try {
errorTryNoCatch();
} catch {}
|