Exception handling

by Anton

JavaScript

console.log('start');
console.log('return value:', testExceptions());
console.log('end');

function testExceptions() {
    try {
        console.log('...try');
        nonExistingFunction();
    } catch (e) {
        console.log('...catch');
        console.log(e);
        throw new Error('Error inside catch!'); // finally is still called, "end" isn't
    } finally {
        console.log('...finally');
        return 1;
    }
    
    return 0;
}