Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const waitFor = (ms) => new Promise(r => setTimeout(r, ms));
- start = async () => {
- try {
- console.log("start");
- c = 1;
- while(c < 10){
- await waitFor(2000)
- console.log('waiting!');
- if(c === 3){
- console.log('errrorr!!')
- throw new Error('dasdas');
- }
- c++
- }
- console.log('end');
- } catch (error) {
- console.log('catched!!!');
- }
- }
- start();
Add Comment
Please, Sign In to add comment