Last active
November 15, 2017 18:36
-
-
Save gad0lin/ff4f5b6650a293aec338e759ea161eff to your computer and use it in GitHub Desktop.
errors catching async
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let b = async function() { | |
throw "bad" | |
} | |
let a = async function() { | |
try { | |
return b(); | |
} catch (e) { | |
console.log(123) | |
} | |
} | |
let c = async function() { | |
try { | |
await a() | |
} catch (e) { | |
console.log("got it") | |
} | |
} | |
c() | |
function intervalFunc() { | |
console.log('Cant stop me now!'); | |
} | |
setInterval(intervalFunc, 1500); | |
// output: got it and then cant stop me now | |
let b = async function() { | |
throw "bad" | |
} | |
let a = async function() { | |
return await b(); | |
} | |
let c = async function() { | |
try { | |
await a() | |
} catch (e) { | |
console.log("got it") | |
} | |
} | |
c() | |
function intervalFunc() { | |
console.log('Cant stop me now!'); | |
} | |
setInterval(intervalFunc, 1500); | |
// outpub: got it and can't stop me now | |
let b = async function() { | |
throw "bad" | |
} | |
let a = async function() { | |
try { | |
return await b(); | |
} catch (e) { | |
console.log("aaa catch") | |
} | |
} | |
let c = async function() { | |
try { | |
await a() | |
} catch (e) { | |
console.log("got it") | |
} | |
} | |
c() | |
function intervalFunc() { | |
console.log('Cant stop me now!'); | |
} | |
setInterval(intervalFunc, 1500); | |
// output: got it and can't stop me now | |
let b = async function() { | |
throw "bad" | |
} | |
let a = function() { | |
try { | |
return b(); | |
} catch (e) { | |
console.log("aaa catch") | |
} | |
} | |
let c = async function() { | |
try { | |
await a() | |
} catch (e) { | |
console.log("got it") | |
} | |
} | |
c() | |
function intervalFunc() { | |
console.log('Cant stop me now!'); | |
} | |
setInterval(intervalFunc, 1500); | |
// output: got it and can't stop me now | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment