JSFiddle - React, Tailwind, and code Playground

HTML

<html>
    <body>
        <div id="result">
            
        </div>
    </body>
</html>

JavaScript

var prom = $.when("promise");

$.when(prom).done(function(x) {
    $("#result").append('1st time<br>');
});

$.when(prom).done(function(x) {
    $("#result").append('2nd time<br>');
    throw 'error';
});

$.when(prom).done(function(x) {
    $("#result").append('3rd time<br>');
});