If ws.send throws an exception for the code below, I want to ensure that I stop recursively sending and that the client thread ends.
function newAlarm(ws)
{
ws.send(alarm);
}
function loop(f,t)
{
setTimeout(() => loop(f,t), t);
f();
}
loop(() => newAlarm(ws),10000);
I understand that to catch the error for ws.send, I do the following: ws.send(alarm, err => {if(!err){...}}) But I can't figure out how to do this for setTimeout.