throw-exception-stack-location.js (843B)
1 function throwValue(value) { 2 throw value; 3 } 4 5 // Test try-finally keep the exception stack. 6 function testFinally() { 7 function f() { 8 try { 9 throwValue("exception-value"); 10 } finally { 11 for (let i = 0; i < 100; ++i) { 12 // OSR 13 } 14 } 15 } 16 17 let info = getExceptionInfo(f); 18 assertEq(info.exception, "exception-value"); 19 assertEq(info.stack.includes("throwValue"), true); 20 } 21 testFinally(); 22 23 // Test try-catch-finally keep the exception stack. 24 function testCatchFinally() { 25 function f() { 26 try { 27 throw null; 28 } catch { 29 throwValue("exception-value"); 30 } finally { 31 for (let i = 0; i < 100; ++i) { 32 // OSR 33 } 34 } 35 } 36 37 let info = getExceptionInfo(f); 38 assertEq(info.exception, "exception-value"); 39 assertEq(info.stack.includes("throwValue"), true); 40 } 41 testCatchFinally();