Try Catch



examples/other/try_catch.html
<input type="number" id="a">
<input type="number" id="b">
<button id="calc">Divide</button>
<div id="result"></div>

<script>

// Apparently dividing by 0 is not an exception in JavaScript
// So I have stupid other 

function calc() {
    console.log('calc');
    const res = div(document.getElementById('a').value, document.getElementById('b').value);
    console.log(res);
    document.getElementById('result').innerHTML = res;
}

function div(a, b) {
    console.log(`div(${a},${b})`);
    try {
        const c = a / b;
        if (c == 0) {
            handle_zero();
        }
        return c;
    } catch(error) {
        console.log(`Eception: ${error}`);
    }
}
document.getElementById('calc').addEventListener('click', calc);

</script>