I would like to handle async timeouts by awaiting the execution and re-executing a function including error handling after it fails.
Pseudo code:
01 call and await async function update()
02 if no error -> continue to line 05
03 sleep for 10000ms
04 Jump to line 01 //call update() again and handle possible errors
05 //continues execution
seems simple, but I cant get the asynchronous part working
Some common structure without any promise handling
let success = false;
while (!success) {
try{
update()
success = true;
} catch (e) {
setTimeout(() => {},10000)
}
}
I know that I should be working with .catch and promises, but cant figure out how.
Thanks for any help and explanations