Deliver the following architecture:
window.addEventListener("error", handleException, false);
function handleException(I_sMsg) {
if (I_sMsg.stack) {
sMsg = I_sMsg.stack.replaceAll(getBaseURL(), "");
alert(sMsg);
} else if (I_sMsg.message) {
alert(I_sMsg.message);
}
return cancelEvent(I_sMsg);
}
Now anyone throw new Error("description");will go through the first part of the if statement and have a good stack so you can parse the urls.
It also works for unexpected exceptions, resulting in the following message (in this case, after calling a non-existent function bibi())

After further study, my structure uses some kind of home task management (as shown in the stack in fact), where each action belongs to the task.
()
try {
oTask.func.apply(oTask.obj, oTask.prms);
} catch(ex) {
handleException(ex);
return false;
}
, , catch try. , . .
, , , , api.js , .