JSFiddle - React, Tailwind, and code Playground

JavaScript

console.log("starting...");

function throwError(text) {
    return function() {
        console.log("Throwing error:", text);
        throw Error(text);
    }
}

$.get("http://example.com/")
    .error(throwError("in ajax"));

setTimeout(throwError("in timeout"), 100);